Message ID | 20211130105117.GH5827@kili (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | [1/2] hwmon: (asus_wmi_ec_sensors) fix array overflow | expand |
On Tue, Nov 30, 2021 at 01:51:17PM +0300, Dan Carpenter wrote: > Smatch detects this array overflow: > > drivers/hwmon/asus_wmi_sensors.c:569 asus_wmi_configure_sensor_setup() > error: buffer overflow 'hwmon_attributes' 8 <= 9 > > The hwmon_attributes[] array should have "hwmon_max" so that it gets > larger when more attributes are added. > > Fixes: 9d07e54a25b8 ("hwmon: (asus_wmi_sensors) Support X370 Asus WMI.") > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Applied. Thanks, Guenter > --- > drivers/hwmon/asus_wmi_sensors.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/hwmon/asus_wmi_sensors.c b/drivers/hwmon/asus_wmi_sensors.c > index 67af15d99396..c80eee874b6c 100644 > --- a/drivers/hwmon/asus_wmi_sensors.c > +++ b/drivers/hwmon/asus_wmi_sensors.c > @@ -125,7 +125,7 @@ static enum hwmon_sensor_types asus_data_types[] = { > [WATER_FLOW] = hwmon_fan, > }; > > -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,
diff --git a/drivers/hwmon/asus_wmi_sensors.c b/drivers/hwmon/asus_wmi_sensors.c index 67af15d99396..c80eee874b6c 100644 --- a/drivers/hwmon/asus_wmi_sensors.c +++ b/drivers/hwmon/asus_wmi_sensors.c @@ -125,7 +125,7 @@ static enum hwmon_sensor_types asus_data_types[] = { [WATER_FLOW] = hwmon_fan, }; -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,
Smatch detects this array overflow: drivers/hwmon/asus_wmi_sensors.c:569 asus_wmi_configure_sensor_setup() error: buffer overflow 'hwmon_attributes' 8 <= 9 The hwmon_attributes[] array should have "hwmon_max" so that it gets larger when more attributes are added. Fixes: 9d07e54a25b8 ("hwmon: (asus_wmi_sensors) Support X370 Asus WMI.") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> --- drivers/hwmon/asus_wmi_sensors.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)