[PATCH linux dev-4.13] hwmon (occ): Fix an infinite for loop issue
Lei YU
mine260309 at gmail.com
Wed Mar 21 14:22:12 AEDT 2018
The for loop without ++i cause either infinite loop or random memory
access issues, e.g. unable to handle kernel NULL or kernel oops in
snprintf.
Fix it by adding ++i in the for loop.
Signed-off-by: Lei YU <mine260309 at gmail.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 d0b2a29..88c3291 100644
--- a/drivers/hwmon/occ/common.c
+++ b/drivers/hwmon/occ/common.c
@@ -916,7 +916,7 @@ static int occ_setup_sensor_attrs(struct occ *occ)
/* Special case for many-attribute power sensor. Split it into
* a sensor number per power type, emulating several sensors.
*/
- for (i = 0; i < sensors->power.num_sensors; ) {
+ for (i = 0; i < sensors->power.num_sensors; ++i) {
s = (i * 4) + 1;
snprintf(attr->name, sizeof(attr->name),
--
2.7.4
More information about the openbmc
mailing list