hwmon: (nct6775-core) Explicitly initialize nct6775_device_names indexes
authorGuenter Roeck <linux@roeck-us.net>
Thu, 16 Nov 2023 23:57:45 +0000 (15:57 -0800)
committerGuenter Roeck <linux@roeck-us.net>
Mon, 11 Dec 2023 14:20:54 +0000 (06:20 -0800)
Changing the "kinds" enum start value to be 1-indexed instead of
0-indexed caused look-ups in nct6775_device_names[] to be misaligned or
off the end.

Initialize the string list with explicit indexes.

Cc: Rob Herring <robh@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Fixes: 10a0575ea09d ("hwmon: nct6775-i2c: Use i2c_get_match_data()")
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/nct6775-core.c

index d928eb8ae5a379effe351785abf00af9e140c964..7534d5c657bdd5a880f0d222f786613be71a0eae 100644 (file)
 
 /* used to set data->name = nct6775_device_names[data->sio_kind] */
 static const char * const nct6775_device_names[] = {
-       "nct6106",
-       "nct6116",
-       "nct6775",
-       "nct6776",
-       "nct6779",
-       "nct6791",
-       "nct6792",
-       "nct6793",
-       "nct6795",
-       "nct6796",
-       "nct6797",
-       "nct6798",
-       "nct6799",
+       [nct6106] = "nct6106",
+       [nct6116] = "nct6116",
+       [nct6775] = "nct6775",
+       [nct6776] = "nct6776",
+       [nct6779] = "nct6779",
+       [nct6791] = "nct6791",
+       [nct6792] = "nct6792",
+       [nct6793] = "nct6793",
+       [nct6795] = "nct6795",
+       [nct6796] = "nct6796",
+       [nct6797] = "nct6797",
+       [nct6798] = "nct6798",
+       [nct6799] = "nct6799",
 };
 
 /* Common and NCT6775 specific data */