diff mbox series

hwmon: (nct6775) Fix non-existent ALARM warning

Message ID 20230918184722.2033225-1-ahmad@khalifa.ws (mailing list archive)
State Accepted
Headers show
Series hwmon: (nct6775) Fix non-existent ALARM warning | expand

Commit Message

Ahmad Khalifa Sept. 18, 2023, 6:47 p.m. UTC
Skip non-existent ALARM attribute to avoid a shift-out-of-bounds
dmesg warning.

Reported-by: Doug Smythies <dsmythies@telus.net>
Closes: https://lore.kernel.org/linux-hwmon/ZQVzdlHgWdFhOVyQ@debian.me/T/#mc69b690660eb50734a6b07506d74a119e0266f1b
Fixes: b7f1f7b2523a ("hwmon: (nct6775) Additional TEMP registers for nct6799")
Signed-off-by: Ahmad Khalifa <ahmad@khalifa.ws>
---
 drivers/hwmon/nct6775-core.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Guenter Roeck Sept. 18, 2023, 6:53 p.m. UTC | #1
On Mon, Sep 18, 2023 at 07:47:22PM +0100, Ahmad Khalifa wrote:
> Skip non-existent ALARM attribute to avoid a shift-out-of-bounds
> dmesg warning.
> 
> Reported-by: Doug Smythies <dsmythies@telus.net>
> Closes: https://lore.kernel.org/linux-hwmon/ZQVzdlHgWdFhOVyQ@debian.me/T/#mc69b690660eb50734a6b07506d74a119e0266f1b
> Fixes: b7f1f7b2523a ("hwmon: (nct6775) Additional TEMP registers for nct6799")
> Signed-off-by: Ahmad Khalifa <ahmad@khalifa.ws>

Applied.

Thanks,
Guenter

> ---
>  drivers/hwmon/nct6775-core.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c
> index 02a71244fc3b..b5b81bd83bb1 100644
> --- a/drivers/hwmon/nct6775-core.c
> +++ b/drivers/hwmon/nct6775-core.c
> @@ -1910,6 +1910,10 @@ static umode_t nct6775_in_is_visible(struct kobject *kobj,
>  	struct device *dev = kobj_to_dev(kobj);
>  	struct nct6775_data *data = dev_get_drvdata(dev);
>  	int in = index / 5;	/* voltage index */
> +	int nr = index % 5;	/* attribute index */
> +
> +	if (nr == 1 && data->ALARM_BITS[in] == -1)
> +		return 0;
>  
>  	if (!(data->have_in & BIT(in)))
>  		return 0;
diff mbox series

Patch

diff --git a/drivers/hwmon/nct6775-core.c b/drivers/hwmon/nct6775-core.c
index 02a71244fc3b..b5b81bd83bb1 100644
--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -1910,6 +1910,10 @@  static umode_t nct6775_in_is_visible(struct kobject *kobj,
 	struct device *dev = kobj_to_dev(kobj);
 	struct nct6775_data *data = dev_get_drvdata(dev);
 	int in = index / 5;	/* voltage index */
+	int nr = index % 5;	/* attribute index */
+
+	if (nr == 1 && data->ALARM_BITS[in] == -1)
+		return 0;
 
 	if (!(data->have_in & BIT(in)))
 		return 0;