platform-mc: Fix null deref in initTerminus Commit [1] changed initTerminus() to snapshot TIDs before iterating, but the loop still looks up each terminus by TID using operator[]. If a terminus is removed between iterations, operator[] silently inserts a null entry instead of failing, causing a null pointer dereference on the next access. Add a contains() guard before the lookup so that removed TIDs are skipped, consistent with the existing guards after each co_await. Tested: On a Yosemite 4 platform, repeated chassis power cycles trigger the race. With the fix applied and a temporary log confirming the guard fires, initTerminus completes without crash. Reference: [1] https://gerrit.openbmc.org/c/openbmc/pldm/+/89709 Change-Id: I948d78bfd6087ac2496489752a3291ce5f34eb68 Signed-off-by: Eric Yang <eric.yang.wiwynn@gmail.com>
diff --git a/platform-mc/platform_manager.cpp b/platform-mc/platform_manager.cpp index 93ad701..b6c9d81 100644 --- a/platform-mc/platform_manager.cpp +++ b/platform-mc/platform_manager.cpp
@@ -27,6 +27,13 @@ for (const auto tid : tids) { + // termini[tid] would auto-insert if the TID was erased after the + // snapshot above. + if (!termini.contains(tid)) + { + continue; + } + /* Take a local shared_ptr copy so the Terminus object stays alive even * if the map entry is erased while this coroutine is suspended. */ auto terminus = termini[tid];