summaryrefslogtreecommitdiff
path: root/drivers/hwmon/scmi-hwmon.c
diff options
context:
space:
mode:
authorCristian Marussi <cristian.marussi@arm.com>2020-07-15 15:13:38 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-07-29 11:16:54 +0300
commit1e687db5f29739ab58428f45e50ba90a5b50992a (patch)
tree6a03ed782cd4baf11fb216258c808eca38df63a6 /drivers/hwmon/scmi-hwmon.c
parentebb591b87216e3ecda00d0938e23ecba152f5dc3 (diff)
downloadlinux-1e687db5f29739ab58428f45e50ba90a5b50992a.tar.xz
hwmon: (scmi) Fix potential buffer overflow in scmi_hwmon_probe()
[ Upstream commit 3ce17cd2b94907f6d91b81b32848044b84c97606 ] 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: Cristian Marussi <cristian.marussi@arm.com> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> Link: https://lore.kernel.org/r/20200715121338.GA18761@e119603-lin.cambridge.arm.com Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/hwmon/scmi-hwmon.c')
-rw-r--r--drivers/hwmon/scmi-hwmon.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c
index 91976b6ca300..91bfecdb3f5b 100644
--- a/drivers/hwmon/scmi-hwmon.c
+++ b/drivers/hwmon/scmi-hwmon.c
@@ -99,7 +99,7 @@ static enum hwmon_sensor_types scmi_types[] = {
[ENERGY] = hwmon_energy,
};
-static u32 hwmon_attributes[] = {
+static u32 hwmon_attributes[hwmon_max] = {
[hwmon_chip] = HWMON_C_REGISTER_TZ,
[hwmon_temp] = HWMON_T_INPUT | HWMON_T_LABEL,
[hwmon_in] = HWMON_I_INPUT | HWMON_I_LABEL,