[PATCH linux dev-4.10 2/2] drivers (hwmon): occ: Fix memory allocation for extended sensors

Eddie James eajames at linux.vnet.ibm.com
Fri Oct 27 07:15:13 AEDT 2017


From: "Edward A. James" <eajames at us.ibm.com>

If extended sensors are present, the driver is doing bad memory access
since we weren't allocating enough memory for the extended sensors. Fix
this with proper allocation for extended sensor attributes.

Signed-off-by: Edward A. James <eajames at us.ibm.com>
---
 drivers/hwmon/occ/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hwmon/occ/common.c b/drivers/hwmon/occ/common.c
index 3b9adf4..3175e7b 100644
--- a/drivers/hwmon/occ/common.c
+++ b/drivers/hwmon/occ/common.c
@@ -872,7 +872,7 @@ int occ_setup_sensor_attrs(struct occ *occ)
 
 	switch (sensors->extended.version) {
 	case 1:
-		occ->num_attrs += sensors->extended.num_sensors;
+		occ->num_attrs += (sensors->extended.num_sensors * 3);
 		break;
 	default:
 		sensors->extended.num_sensors = 0;
-- 
1.8.3.1



More information about the openbmc mailing list