[Skiboot] [PATCH 2/8] assert IPMI sensors < max we support
Stewart Smith
stewart at linux.vnet.ibm.com
Tue Nov 17 15:39:01 AEDT 2015
Signed-off-by: Stewart Smith <stewart at linux.vnet.ibm.com>
---
hw/ipmi/ipmi-sensor.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/hw/ipmi/ipmi-sensor.c b/hw/ipmi/ipmi-sensor.c
index c8723aed0e2b..dd63986a511c 100644
--- a/hw/ipmi/ipmi-sensor.c
+++ b/hw/ipmi/ipmi-sensor.c
@@ -25,7 +25,8 @@
#define FW_PROGRESS_SENSOR_TYPE 0x0F
#define BOOT_COUNT_SENSOR_TYPE 0xC3
-static int16_t sensors[255];
+#define MAX_IPMI_SENSORS 255
+static int16_t sensors[MAX_IPMI_SENSORS];
struct set_sensor_req {
u8 sensor_number;
@@ -38,6 +39,7 @@ struct set_sensor_req {
uint8_t ipmi_get_sensor_number(uint8_t sensor_type)
{
+ assert(sensor_type < MAX_IPMI_SENSORS);
return sensors[sensor_type];
}
@@ -125,6 +127,7 @@ void ipmi_sensor_init(void)
}
num = (uint8_t)dt_property_get_cell(num_prop, 0);
type = (uint8_t)dt_property_get_cell(type_prop, 0);
+ assert(type < MAX_IPMI_SENSORS);
sensors[type] = num;
}
}
--
2.1.4
More information about the Skiboot
mailing list