]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.20/hwmon-lm80-fix-missing-unlock-on-error-in-set_fan_di.patch
patches for 4.20
[thirdparty/kernel/stable-queue.git] / queue-4.20 / hwmon-lm80-fix-missing-unlock-on-error-in-set_fan_di.patch
1 From b8043bf2140ad0e4d31a68ee05a4a9dd7cc39bfa Mon Sep 17 00:00:00 2001
2 From: Wei Yongjun <weiyongjun1@huawei.com>
3 Date: Wed, 26 Dec 2018 11:28:24 +0000
4 Subject: hwmon: (lm80) Fix missing unlock on error in set_fan_div()
5
6 [ Upstream commit 07bd14ccc3049f9c0147a91a4227a571f981601a ]
7
8 Add the missing unlock before return from function set_fan_div()
9 in the error handling case.
10
11 Fixes: c9c63915519b ("hwmon: (lm80) fix a missing check of the status of SMBus read")
12 Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
13 Signed-off-by: Guenter Roeck <linux@roeck-us.net>
14 Signed-off-by: Sasha Levin <sashal@kernel.org>
15 ---
16 drivers/hwmon/lm80.c | 4 +++-
17 1 file changed, 3 insertions(+), 1 deletion(-)
18
19 diff --git a/drivers/hwmon/lm80.c b/drivers/hwmon/lm80.c
20 index 0e30fa00204cd..f9b8e3e23a8e8 100644
21 --- a/drivers/hwmon/lm80.c
22 +++ b/drivers/hwmon/lm80.c
23 @@ -393,8 +393,10 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
24 }
25
26 rv = lm80_read_value(client, LM80_REG_FANDIV);
27 - if (rv < 0)
28 + if (rv < 0) {
29 + mutex_unlock(&data->update_lock);
30 return rv;
31 + }
32 reg = (rv & ~(3 << (2 * (nr + 1))))
33 | (data->fan_div[nr] << (2 * (nr + 1)));
34 lm80_write_value(client, LM80_REG_FANDIV, reg);
35 --
36 2.19.1
37