diff mbox

[2/8] assert IPMI sensors < max we support

Message ID 1447735147-25957-2-git-send-email-stewart@linux.vnet.ibm.com
State Accepted
Headers show

Commit Message

Stewart Smith Nov. 17, 2015, 4:39 a.m. UTC
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
---
 hw/ipmi/ipmi-sensor.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox

Patch

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;
 	}
 }