Skip to contentSkip to conversation

hwmon: (nct6775) Fix non-existent ALARM warning

PATCH Applied Ahmad Khalifa 2 participants 2 messages Sep 18, 2023 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwmon: (nct6775) Fix non-existent ALARM warning

Skip non-existent ALARM attribute to avoid a shift-out-of-bounds dmesg warning.

---
 drivers/hwmon/nct6775-core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/hwmon/nct6775-core.c +4 -0
index 02a71244fc3b..b5b81bd83bb1 100644
@@ -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;
Signature · 1 line
2.39.2
maintainer Applied
#1 lore raw
Quoted 7 lines · Ahmad Khalifa

Skip non-existent ALARM attribute to avoid a shift-out-of-bounds dmesg warning.

Applied.

Thanks,
Guenter

Quoted 19 lines
---
 drivers/hwmon/nct6775-core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/hwmon/nct6775-core.c +4 -0
index 02a71244fc3b..b5b81bd83bb1 100644
@@ -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;