]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
6.5-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Nov 2023 10:14:28 +0000 (11:14 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Nov 2023 10:14:28 +0000 (11:14 +0100)
added patches:
hwmon-nct6775-fix-incorrect-variable-reuse-in-fan_div-calculation.patch
series

queue-6.5/hwmon-nct6775-fix-incorrect-variable-reuse-in-fan_div-calculation.patch [new file with mode: 0644]
queue-6.5/series [new file with mode: 0644]

diff --git a/queue-6.5/hwmon-nct6775-fix-incorrect-variable-reuse-in-fan_div-calculation.patch b/queue-6.5/hwmon-nct6775-fix-incorrect-variable-reuse-in-fan_div-calculation.patch
new file mode 100644 (file)
index 0000000..d08a221
--- /dev/null
@@ -0,0 +1,63 @@
+From 920057ad521dc8669e534736c2a12c14ec9fb2d7 Mon Sep 17 00:00:00 2001
+From: Zev Weiss <zev@bewilderbeest.net>
+Date: Fri, 29 Sep 2023 13:08:23 -0700
+Subject: hwmon: (nct6775) Fix incorrect variable reuse in fan_div calculation
+
+From: Zev Weiss <zev@bewilderbeest.net>
+
+commit 920057ad521dc8669e534736c2a12c14ec9fb2d7 upstream.
+
+In the regmap conversion in commit 4ef2774511dc ("hwmon: (nct6775)
+Convert register access to regmap API") I reused the 'reg' variable
+for all three register reads in the fan speed calculation loop in
+nct6775_update_device(), but failed to notice that the value from the
+first one (data->REG_FAN[i]) is actually used in the call to
+nct6775_select_fan_div() at the end of the loop body.  Since that
+patch the register value passed to nct6775_select_fan_div() has been
+(conditionally) incorrectly clobbered with the value of a different
+register than intended, which has in at least some cases resulted in
+fan speeds being adjusted down to zero.
+
+Fix this by using dedicated temporaries for the two intermediate
+register reads instead of 'reg'.
+
+Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
+Fixes: 4ef2774511dc ("hwmon: (nct6775) Convert register access to regmap API")
+Reported-by: Thomas Zajic <zlatko@gmx.at>
+Tested-by: Thomas Zajic <zlatko@gmx.at>
+Cc: stable@vger.kernel.org # v5.19+
+Link: https://lore.kernel.org/r/20230929200822.964-2-zev@bewilderbeest.net
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/hwmon/nct6775-core.c |   12 ++++++++----
+ 1 file changed, 8 insertions(+), 4 deletions(-)
+
+--- a/drivers/hwmon/nct6775-core.c
++++ b/drivers/hwmon/nct6775-core.c
+@@ -1581,17 +1581,21 @@ struct nct6775_data *nct6775_update_devi
+                                                         data->fan_div[i]);
+                       if (data->has_fan_min & BIT(i)) {
+-                              err = nct6775_read_value(data, data->REG_FAN_MIN[i], &reg);
++                              u16 tmp;
++
++                              err = nct6775_read_value(data, data->REG_FAN_MIN[i], &tmp);
+                               if (err)
+                                       goto out;
+-                              data->fan_min[i] = reg;
++                              data->fan_min[i] = tmp;
+                       }
+                       if (data->REG_FAN_PULSES[i]) {
+-                              err = nct6775_read_value(data, data->REG_FAN_PULSES[i], &reg);
++                              u16 tmp;
++
++                              err = nct6775_read_value(data, data->REG_FAN_PULSES[i], &tmp);
+                               if (err)
+                                       goto out;
+-                              data->fan_pulses[i] = (reg >> data->FAN_PULSE_SHIFT[i]) & 0x03;
++                              data->fan_pulses[i] = (tmp >> data->FAN_PULSE_SHIFT[i]) & 0x03;
+                       }
+                       err = nct6775_select_fan_div(dev, data, i, reg);
diff --git a/queue-6.5/series b/queue-6.5/series
new file mode 100644 (file)
index 0000000..a13f33e
--- /dev/null
@@ -0,0 +1 @@
+hwmon-nct6775-fix-incorrect-variable-reuse-in-fan_div-calculation.patch