hwmon: (asus_wmi_ec_sensors) fix array overflow

Smatch detected an array out of bounds error:

    drivers/hwmon/asus_wmi_ec_sensors.c:562 asus_wmi_ec_configure_sensor_setup()
    error: buffer overflow 'hwmon_attributes' 8 <= 9

The hwmon_attributes[] array needs to be declared with "hwmon_max"
elements.

Fixes: c04c7f7bfcbe ("hwmon: (asus_wmi_ec_sensors) Support B550 Asus WMI.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20211130105034.GG5827@kili
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
Dan Carpenter 2021-11-30 13:50:34 +03:00 committed by Guenter Roeck
parent 62cfc05763
commit 34e2bd10ab

View file

@ -41,7 +41,7 @@
#define ASUSWMI_MAX_BUF_LEN 128
#define SENSOR_LABEL_LEN 16
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,