diff mbox series

hwmon: (nct6775-core) Explicitly initialize nct6775_device_names indexes

Message ID 20231117000251.1197405-1-linux@roeck-us.net (mailing list archive)
State Accepted
Headers show
Series hwmon: (nct6775-core) Explicitly initialize nct6775_device_names indexes | expand

Commit Message

Guenter Roeck Nov. 17, 2023, 12:02 a.m. UTC
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: 0a7093e69c1e ("hwmon: nct6775-i2c: Use i2c_get_match_data()")
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/hwmon/nct6775-core.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

Comments

Rob Herring (Arm) Nov. 17, 2023, 1:38 p.m. UTC | #1
On Thu, Nov 16, 2023 at 6:03 PM Guenter Roeck <linux@roeck-us.net> wrote:
>
> 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: 0a7093e69c1e ("hwmon: nct6775-i2c: Use i2c_get_match_data()")
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  drivers/hwmon/nct6775-core.c | 26 +++++++++++++-------------
>  1 file changed, 13 insertions(+), 13 deletions(-)

Sorry I missed that. Thanks for fixing it.

Reviewed-by: Rob Herring <robh@kernel.org>

Rob
diff mbox series

Patch

diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c
index d928eb8ae5a3..7534d5c657bd 100644
--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -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 */