Skip to contentSkip to conversation

hwmon: (nct6775-core) Explicitly initialize nct6775_device_names indexes

PATCH In review Guenter Roeck 2 participants 2 messages Nov 17, 2023 Hardware monitoring

lore
Share & tools
lore

Guenter Roeck

author maintainer
#0 lore raw

PATCH 1/1 hwmon: (nct6775-core) Explicitly initialize nct6775_device_names indexes

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 <[email protected]>
Cc Kees Cook <[email protected]>
Fixes 0a7093e69c1e ("hwmon: nct6775-i2c: Use i2c_get_match_data()")
---
 drivers/hwmon/nct6775-core.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/hwmon/nct6775-core.c +13 -13
index d928eb8ae5a3..7534d5c657bd 100644
@@ -63,19 +63,19 @@
 
 /* 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 */
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Guenter Roeck

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.

Quoted 7 lines
Cc Rob Herring <[email protected]>
Cc Kees Cook <[email protected]>
Fixes 0a7093e69c1e ("hwmon: nct6775-i2c: Use i2c_get_match_data()")
---
 drivers/hwmon/nct6775-core.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

Sorry I missed that. Thanks for fixing it.

Rob