[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200715140922.GA46932@roeck-us.net>
Date: Wed, 15 Jul 2020 07:09:22 -0700
From: Guenter Roeck <linux@...ck-us.net>
To: Cristian Marussi <cristian.marussi@....com>
Cc: linux-kernel@...r.kernel.org, linux-hwmon@...r.kernel.org,
jdelvare@...e.com, sudeep.holla@....com
Subject: Re: [RESEND][PATCH] hwmon: scmi: fix potential buffer overflow in
scmi_hwmon_probe()
On Wed, Jul 15, 2020 at 01:13:38PM +0100, Cristian Marussi wrote:
> 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@....com>
> Reviewed-by: Sudeep Holla <sudeep.holla@....com>
Applied.
Thanks,
Guenter
> ---
> drivers/hwmon/scmi-hwmon.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c
> index 281454c5c5b1..758f66fc9afe 100644
> --- a/drivers/hwmon/scmi-hwmon.c
> +++ b/drivers/hwmon/scmi-hwmon.c
> @@ -149,7 +149,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,
Powered by blists - more mailing lists