Skip to content

Commit 8cfe000

Browse files
groeckgregkh
authored andcommitted
hwmon: (pc87427) Use request_muxed_region for Super-IO accesses
[ Upstream commit 755a9b0 ] Super-IO accesses may fail on a system with no or unmapped LPC bus. Also, other drivers may attempt to access the LPC bus at the same time, resulting in undefined behavior. Use request_muxed_region() to ensure that IO access on the requested address space is supported, and to ensure that access by multiple drivers is synchronized. Fixes: ba224e2 ("hwmon: New PC87427 hardware monitoring driver") Reported-by: Kefeng Wang <[email protected]> Reported-by: John Garry <[email protected]> Cc: John Garry <[email protected]> Acked-by: John Garry <[email protected]> Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 48b31e8 commit 8cfe000

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

drivers/hwmon/pc87427.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ static const char *logdev_str[2] = { DRVNAME " FMC", DRVNAME " HMC" };
106106
#define LD_IN 1
107107
#define LD_TEMP 1
108108

109+
static inline int superio_enter(int sioaddr)
110+
{
111+
if (!request_muxed_region(sioaddr, 2, DRVNAME))
112+
return -EBUSY;
113+
return 0;
114+
}
115+
109116
static inline void superio_outb(int sioaddr, int reg, int val)
110117
{
111118
outb(reg, sioaddr);
@@ -122,6 +129,7 @@ static inline void superio_exit(int sioaddr)
122129
{
123130
outb(0x02, sioaddr);
124131
outb(0x02, sioaddr + 1);
132+
release_region(sioaddr, 2);
125133
}
126134

127135
/*
@@ -1220,7 +1228,11 @@ static int __init pc87427_find(int sioaddr, struct pc87427_sio_data *sio_data)
12201228
{
12211229
u16 val;
12221230
u8 cfg, cfg_b;
1223-
int i, err = 0;
1231+
int i, err;
1232+
1233+
err = superio_enter(sioaddr);
1234+
if (err)
1235+
return err;
12241236

12251237
/* Identify device */
12261238
val = force_id ? force_id : superio_inb(sioaddr, SIOREG_DEVID);

0 commit comments

Comments
 (0)