Home Home > GIT Browse > SLE15-AZURE
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2019-02-14 11:45:40 +0100
committerTakashi Iwai <tiwai@suse.de>2019-02-14 11:45:41 +0100
commitb7264877121d89972f08333932efa3e79f41b89c (patch)
tree550e0701352ffda2c2afa56e5ea2c041828c0cd2
parent692e50442e95c813c0619077bcadc517021fec67 (diff)
hwmon: (lm80) fix a missing check of the status of SMBus read
(bsc#1051510).
-rw-r--r--patches.drivers/hwmon-lm80-fix-a-missing-check-of-the-status-of-SMBu.patch60
-rw-r--r--series.conf1
2 files changed, 61 insertions, 0 deletions
diff --git a/patches.drivers/hwmon-lm80-fix-a-missing-check-of-the-status-of-SMBu.patch b/patches.drivers/hwmon-lm80-fix-a-missing-check-of-the-status-of-SMBu.patch
new file mode 100644
index 0000000000..73cc3da3ec
--- /dev/null
+++ b/patches.drivers/hwmon-lm80-fix-a-missing-check-of-the-status-of-SMBu.patch
@@ -0,0 +1,60 @@
+From c9c63915519b1def7043b184680f33c24cd49d7b Mon Sep 17 00:00:00 2001
+From: Kangjie Lu <kjlu@umn.edu>
+Date: Fri, 21 Dec 2018 13:01:33 -0600
+Subject: [PATCH] hwmon: (lm80) fix a missing check of the status of SMBus read
+Git-commit: c9c63915519b1def7043b184680f33c24cd49d7b
+Patch-mainline: v5.0-rc1
+References: bsc#1051510
+
+If lm80_read_value() fails, it returns a negative number instead of the
+correct read data. Therefore, we should avoid using the data if it
+fails.
+
+The fix checks if lm80_read_value() fails, and if so, returns with the
+error number.
+
+Signed-off-by: Kangjie Lu <kjlu@umn.edu>
+[groeck: One variable for return values is enough]
+Signed-off-by: Guenter Roeck <linux@roeck-us.net>
+Acked-by: Takashi Iwai <tiwai@suse.de>
+
+---
+ drivers/hwmon/lm80.c | 15 ++++++++++-----
+ 1 file changed, 10 insertions(+), 5 deletions(-)
+
+diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
+index 08e3945a6fbf..04f9df0d2341 100644
+--- a/drivers/hwmon/lm80.c
++++ b/drivers/hwmon/lm80.c
+@@ -360,9 +360,11 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
+ struct i2c_client *client = data->client;
+ unsigned long min, val;
+ u8 reg;
+- int err = kstrtoul(buf, 10, &val);
+- if (err < 0)
+- return err;
++ int rv;
++
++ rv = kstrtoul(buf, 10, &val);
++ if (rv < 0)
++ return rv;
+
+ /* Save fan_min */
+ mutex_lock(&data->update_lock);
+@@ -390,8 +392,11 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
+ return -EINVAL;
+ }
+
+- reg = (lm80_read_value(client, LM80_REG_FANDIV) &
+- ~(3 << (2 * (nr + 1)))) | (data->fan_div[nr] << (2 * (nr + 1)));
++ rv = lm80_read_value(client, LM80_REG_FANDIV);
++ if (rv < 0)
++ return rv;
++ reg = (rv & ~(3 << (2 * (nr + 1))))
++ | (data->fan_div[nr] << (2 * (nr + 1)));
+ lm80_write_value(client, LM80_REG_FANDIV, reg);
+
+ /* Restore fan_min */
+--
+2.16.4
+
diff --git a/series.conf b/series.conf
index e8f395c94d..76070b6ebf 100644
--- a/series.conf
+++ b/series.conf
@@ -20068,6 +20068,7 @@
patches.fixes/mm-migrate-lock-buffers-before-migrate_page_move_map.patch
patches.fixes/mm-migrate-provide-buffer_migrate_page_norefs.patch
patches.fixes/blkdev-avoid-migration-stalls-for-blkdev-pages.patch
+ patches.drivers/hwmon-lm80-fix-a-missing-check-of-the-status-of-SMBu.patch
patches.drivers/gpio-pl061-Move-irq_chip-definition-inside-struct-pl.patch
patches.drivers/gpiolib-Fix-return-value-of-gpio_to_desc-stub-if-GPI.patch
patches.drivers/power-supply-olpc_battery-correct-the-temperature-un.patch