]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.9.180/hwmon-vt1211-use-request_muxed_region-for-super-io-a.patch
Linux 4.9.180
[thirdparty/kernel/stable-queue.git] / releases / 4.9.180 / hwmon-vt1211-use-request_muxed_region-for-super-io-a.patch
1 From 3bc527587a789c36f995437a91ae4d1f0363bfbf Mon Sep 17 00:00:00 2001
2 From: Guenter Roeck <linux@roeck-us.net>
3 Date: Fri, 5 Apr 2019 08:53:08 -0700
4 Subject: hwmon: (vt1211) Use request_muxed_region for Super-IO accesses
5
6 [ Upstream commit 14b97ba5c20056102b3dd22696bf17b057e60976 ]
7
8 Super-IO accesses may fail on a system with no or unmapped LPC bus.
9
10 Also, other drivers may attempt to access the LPC bus at the same time,
11 resulting in undefined behavior.
12
13 Use request_muxed_region() to ensure that IO access on the requested
14 address space is supported, and to ensure that access by multiple drivers
15 is synchronized.
16
17 Fixes: 2219cd81a6cd ("hwmon/vt1211: Add probing of alternate config index port")
18 Signed-off-by: Guenter Roeck <linux@roeck-us.net>
19 Signed-off-by: Sasha Levin <sashal@kernel.org>
20 ---
21 drivers/hwmon/vt1211.c | 15 ++++++++++++---
22 1 file changed, 12 insertions(+), 3 deletions(-)
23
24 diff --git a/drivers/hwmon/vt1211.c b/drivers/hwmon/vt1211.c
25 index 3a6bfa51cb94f..95d5e8ec8b7fc 100644
26 --- a/drivers/hwmon/vt1211.c
27 +++ b/drivers/hwmon/vt1211.c
28 @@ -226,15 +226,21 @@ static inline void superio_select(int sio_cip, int ldn)
29 outb(ldn, sio_cip + 1);
30 }
31
32 -static inline void superio_enter(int sio_cip)
33 +static inline int superio_enter(int sio_cip)
34 {
35 + if (!request_muxed_region(sio_cip, 2, DRVNAME))
36 + return -EBUSY;
37 +
38 outb(0x87, sio_cip);
39 outb(0x87, sio_cip);
40 +
41 + return 0;
42 }
43
44 static inline void superio_exit(int sio_cip)
45 {
46 outb(0xaa, sio_cip);
47 + release_region(sio_cip, 2);
48 }
49
50 /* ---------------------------------------------------------------------
51 @@ -1282,11 +1288,14 @@ static int __init vt1211_device_add(unsigned short address)
52
53 static int __init vt1211_find(int sio_cip, unsigned short *address)
54 {
55 - int err = -ENODEV;
56 + int err;
57 int devid;
58
59 - superio_enter(sio_cip);
60 + err = superio_enter(sio_cip);
61 + if (err)
62 + return err;
63
64 + err = -ENODEV;
65 devid = force_id ? force_id : superio_inb(sio_cip, SIO_VT1211_DEVID);
66 if (devid != SIO_VT1211_ID)
67 goto EXIT;
68 --
69 2.20.1
70