Checking nullptr of busmap[0]
If no device in i2cbus2 under /dev, busmap[0] would be nullptr.
So initialize busmap[0] for this case.
Change-Id: I019bd850474af6b1763b8b71c14d73a233fe881a
Signed-off-by: Helen Huang <he.huang@linux.intel.com>
diff --git a/src/FruDevice.cpp b/src/FruDevice.cpp
index 79e142a..6eaccbe 100644
--- a/src/FruDevice.cpp
+++ b/src/FruDevice.cpp
@@ -1489,7 +1489,10 @@
std::vector<uint8_t> baseboardFRU;
if (readBaseboardFRU(baseboardFRU))
{
- busmap[0]->emplace(0, baseboardFRU);
+ // If no device on i2c bus 0, the insertion will happen.
+ auto bus0 =
+ busmap.try_emplace(0, std::make_shared<DeviceMap>());
+ bus0.first->second->emplace(0, baseboardFRU);
}
for (auto& devicemap : busmap)
{