]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
hwmon: (scmi) Fix potential buffer overflow in scmi_hwmon_probe()
authorCristian Marussi <cristian.marussi@arm.com>
Wed, 15 Jul 2020 12:13:38 +0000 (13:13 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 29 Jul 2020 08:19:53 +0000 (10:19 +0200)
commitb6914cfbdc02f8e7a423c1be350833573e13c667
treee8b2cd42e334bbaeddd849f8a76488f183b9dbf8
parent69187e3bca413d772780bb5f696cd508597d2cd3
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>
drivers/hwmon/scmi-hwmon.c