[PATCH 6.1 609/609] hwmon: (nct6775) Fix non-existent ALARM warning

Greg Kroah-Hartman <[email protected]>
Newsgroups dev.linux.lists.patches,org.kernel.vger.stable
Message-ID <[email protected]>
6.1-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Ahmad Khalifa <[email protected]>

commit 2dd1d862817b850787f4755c05d55e5aeb76dd08 upstream.

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

Reported-by: Doug Smythies <[email protected]>
Closes: https://lore.kernel.org/linux-hwmon/[email protected]/T/#mc69b690660eb50734a6b07506d74a119e0266f1b
Fixes: b7f1f7b2523a ("hwmon: (nct6775) Additional TEMP registers for nct6799")
Signed-off-by: Ahmad Khalifa <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Guenter Roeck <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
 drivers/hwmon/nct6775-core.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/drivers/hwmon/nct6775-core.c
+++ b/drivers/hwmon/nct6775-core.c
@@ -1911,6 +1911,10 @@ static umode_t nct6775_in_is_visible(str
 	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;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.