Commit 3ce17cd2 authored by Cristian Marussi's avatar Cristian Marussi Committed by Guenter Roeck

hwmon: (scmi) Fix potential buffer overflow in scmi_hwmon_probe()

SMATCH detected a potential buffer overflow in the manipulation of
hwmon_attributes array inside the scmi_hwmon_probe function:

drivers/hwmon/scmi-hwmon.c:226
 scmi_hwmon_probe() error: buffer overflow 'hwmon_attributes' 6 <= 9

Fix it by statically declaring the size of the array as the maximum
possible as defined by hwmon_max define.
Signed-off-by: default avatarCristian Marussi <cristian.marussi@arm.com>
Reviewed-by: default avatarSudeep Holla <sudeep.holla@arm.com>
Link: https://lore.kernel.org/r/20200715121338.GA18761@e119603-lin.cambridge.arm.comSigned-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent 8a03746c
...@@ -147,7 +147,7 @@ static enum hwmon_sensor_types scmi_types[] = { ...@@ -147,7 +147,7 @@ static enum hwmon_sensor_types scmi_types[] = {
[ENERGY] = hwmon_energy, [ENERGY] = hwmon_energy,
}; };
static u32 hwmon_attributes[] = { static u32 hwmon_attributes[hwmon_max] = {
[hwmon_chip] = HWMON_C_REGISTER_TZ, [hwmon_chip] = HWMON_C_REGISTER_TZ,
[hwmon_temp] = HWMON_T_INPUT | HWMON_T_LABEL, [hwmon_temp] = HWMON_T_INPUT | HWMON_T_LABEL,
[hwmon_in] = HWMON_I_INPUT | HWMON_I_LABEL, [hwmon_in] = HWMON_I_INPUT | HWMON_I_LABEL,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment