summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Feist <james.feist@linux.intel.com>2020-02-06 16:25:27 -0800
committerJames Feist <james.feist@linux.intel.com>2020-02-10 20:23:16 +0000
commit6ee7f774bf6393d48c7215e02d6dbf00322bc9f5 (patch)
tree8cc454e568e5533033c92a846cd99ecd1e3488d7
parent3c5a376e005d97f5d586c5aa163267eb3b0381aa (diff)
downloadbmcweb-6ee7f774bf6393d48c7215e02d6dbf00322bc9f5.tar.gz
bmcweb-6ee7f774bf6393d48c7215e02d6dbf00322bc9f5.zip
PID: Don't attempt to delete unknown objects
This puts a block in to return early if we are asked to delete something we can't find on D-Bus. This code path was creating a segfault, but theres no reason to continue after we can't find an object we are asked to delete, so we can just avoid it. Also clean up the end iterator dereference so it doesn't happen in any other path. Tested: Segfault goes away Change-Id: I33622e5e8ab09fba0681e4f86f4a7068f6ef0be7 Signed-off-by: James Feist <james.feist@linux.intel.com>
-rw-r--r--redfish-core/lib/managers.hpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp
index dca5933..623f8fe 100644
--- a/redfish-core/lib/managers.hpp
+++ b/redfish-core/lib/managers.hpp
@@ -666,6 +666,8 @@ static CreatePIDRet createPidInterface(
messages::propertyUnknown(response->res, type);
return CreatePIDRet::fail;
}
+
+ BMCWEB_LOG_DEBUG << "del " << path << " " << iface << "\n";
// delete interface
crow::connections::systemBus->async_method_call(
[response, path](const boost::system::error_code ec) {
@@ -1370,12 +1372,16 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues>
{
continue;
}
+ BMCWEB_LOG_DEBUG << *container;
+
std::string& type = containerPair.first;
for (nlohmann::json::iterator it = container->begin();
it != container->end(); it++)
{
const auto& name = it.key();
+ BMCWEB_LOG_DEBUG << "looking for " << name;
+
auto pathItr =
std::find_if(managedObj.begin(), managedObj.end(),
[&name](const auto& obj) {
@@ -1391,6 +1397,8 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues>
// determines if we're patching entity-manager or
// creating a new object
bool createNewObject = (pathItr == managedObj.end());
+ BMCWEB_LOG_DEBUG << "Found = " << !createNewObject;
+
std::string iface;
if (type == "PidControllers" || type == "FanControllers")
{
@@ -1423,13 +1431,27 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues>
createNewObject = true;
}
}
+
+ if (createNewObject && it.value() == nullptr)
+ {
+ // can't delete a non-existant object
+ messages::invalidObject(response->res, name);
+ continue;
+ }
+
+ std::string path;
+ if (pathItr != managedObj.end())
+ {
+ path = pathItr->first.str;
+ }
+
BMCWEB_LOG_DEBUG << "Create new = " << createNewObject << "\n";
output["Name"] = boost::replace_all_copy(name, "_", " ");
std::string chassis;
CreatePIDRet ret = createPidInterface(
- response, type, it, pathItr->first.str, managedObj,
- createNewObject, output, chassis, currentProfile);
+ response, type, it, path, managedObj, createNewObject,
+ output, chassis, currentProfile);
if (ret == CreatePIDRet::fail)
{
return;
@@ -1457,8 +1479,7 @@ struct SetPIDValues : std::enable_shared_from_this<SetPIDValues>
}
messages::success(response->res);
},
- "xyz.openbmc_project.EntityManager",
- pathItr->first.str,
+ "xyz.openbmc_project.EntityManager", path,
"org.freedesktop.DBus.Properties", "Set", iface,
property.first, property.second);
}
OpenPOWER on IntegriCloud