[PATCH] hwmon: (dell-smm): Fix off-by-one error in dell_smm_is_visible()

Armin Wolf posted 1 patch 2 weeks, 1 day ago
drivers/hwmon/dell-smm-hwmon.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] hwmon: (dell-smm): Fix off-by-one error in dell_smm_is_visible()
Posted by Armin Wolf 2 weeks, 1 day ago
The documentation states that on machines supporting only global
fan mode control, the pwmX_enable attributes should only be created
for the first fan channel (pwm1_enable, aka channel 0).

Fix the off-by-one error caused by the fact that fan channels have
a zero-based index.

Cc: stable@vger.kernel.org
Fixes: 1c1658058c99 ("hwmon: (dell-smm) Add support for automatic fan mode")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
---
 drivers/hwmon/dell-smm-hwmon.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
index 683baf361c4c..a34753fc2973 100644
--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -861,9 +861,9 @@ static umode_t dell_smm_is_visible(const void *drvdata, enum hwmon_sensor_types
 			if (auto_fan) {
 				/*
 				 * The setting affects all fans, so only create a
-				 * single attribute.
+				 * single attribute for the first fan channel.
 				 */
-				if (channel != 1)
+				if (channel != 0)
 					return 0;
 
 				/*
-- 
2.39.5
Re: [PATCH] hwmon: (dell-smm): Fix off-by-one error in dell_smm_is_visible()
Posted by Guenter Roeck 2 weeks ago
On Wed, Dec 03, 2025 at 09:21:09PM +0100, Armin Wolf wrote:
> The documentation states that on machines supporting only global
> fan mode control, the pwmX_enable attributes should only be created
> for the first fan channel (pwm1_enable, aka channel 0).
> 
> Fix the off-by-one error caused by the fact that fan channels have
> a zero-based index.
> 
> Cc: stable@vger.kernel.org
> Fixes: 1c1658058c99 ("hwmon: (dell-smm) Add support for automatic fan mode")
> Signed-off-by: Armin Wolf <W_Armin@gmx.de>

Applied.

Thanks,
Guenter