PLDM: Restrain from adding duplicate TL PDRs

This commit inhibits adding the duplicate terminus locator PDRs
to the repo. When the PDRs are removed based on the
terminus handle, the terminus locator PDR info is also
deleted from the map.

Tested with the normal poweron.

Change-Id: Ib973a41dc42324f9b5453a5f1a6592dc306729ff
Signed-off-by: Pavithra Barithaya <pavithra.b@ibm.com>
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index fe825d7..4728bb6 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -27,7 +27,6 @@
 {
 namespace platform
 {
-
 using InternalFailure =
     sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
 
@@ -552,13 +551,18 @@
             // We cannot get the Repo change event from the Terminus
             // that is not already added to the BMC repository
 
-            for (const auto& [terminusHandle, terminusInfo] :
-                 hostPDRHandler->tlPDRInfo)
+            for (auto it = hostPDRHandler->tlPDRInfo.cbegin();
+                 it != hostPDRHandler->tlPDRInfo.cend();)
             {
-                if (std::get<0>(terminusInfo) == tid)
+                if (std::get<0>(it->second) == tid)
                 {
                     pldm_pdr_remove_pdrs_by_terminus_handle(pdrRepo.getPdr(),
-                                                            terminusHandle);
+                                                            it->first);
+                    hostPDRHandler->tlPDRInfo.erase(it++);
+                }
+                else
+                {
+                    ++it;
                 }
             }
         }