summaryrefslogtreecommitdiffstats
path: root/sensorhandler.cpp
diff options
context:
space:
mode:
authorLei YU <mine260309@gmail.com>2018-04-03 15:14:49 +0800
committerVernon Mauery <vernon.mauery@linux.intel.com>2018-04-10 19:47:13 +0000
commit91875f7749c21f336fc02c957609cb8a24e940b6 (patch)
treeee462ebbb13b768ba02113eb322f99774633285b /sensorhandler.cpp
parent65a17a77c25af2e8585bdec21cf004cfb5297ed0 (diff)
downloadphosphor-host-ipmid-91875f7749c21f336fc02c957609cb8a24e940b6.tar.gz
phosphor-host-ipmid-91875f7749c21f336fc02c957609cb8a24e940b6.zip
Handle sensors that can not be found in SystemManager
When a sensor id is not managed in yaml the code tries to get it from legacy SystemManager; And when the sensor id can not be found in SystemManager, it returns empty path, and cause segment fault. This commit makes it return -EINVAL when path is empty, and thus the code will handle this case properly without crash. Resolves openbmc/openbmc#3062 Tested: Boot host without ipmid crash on Romulus. Change-Id: I4240b9be54824543b5e795e898330aeb02c5eb90 Signed-off-by: Lei YU <mine260309@gmail.com>
Diffstat (limited to 'sensorhandler.cpp')
-rw-r--r--sensorhandler.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/sensorhandler.cpp b/sensorhandler.cpp
index 4fabac5..3a47e20 100644
--- a/sensorhandler.cpp
+++ b/sensorhandler.cpp
@@ -105,6 +105,13 @@ int legacy_dbus_openbmc_path(const char *type, const uint8_t num, dbus_interface
goto final;
}
+ if (strlen(str2) == 0)
+ {
+ // Path being empty occurs when the sensor id is not in SystemManager
+ r = -EINVAL;
+ goto final;
+ }
+
r = get_bus_for_path(str2, &str1);
if (r < 0) {
fprintf(stderr, "Failed to get %s busname: %s\n",
@@ -311,7 +318,7 @@ uint8_t find_type_for_sensor_number(uint8_t num) {
r = find_openbmc_path(num, &dbus_if);
if (r < 0) {
fprintf(stderr, "Could not find sensor %d\n", num);
- return r;
+ return 0;
}
return get_type_from_interface(dbus_if);
}
OpenPOWER on IntegriCloud