Skip to content

Commit 73e6ff7

Browse files
committed
hwmon: (f71805f) Use request_muxed_region for Super-IO accesses
Super-IO accesses may fail on a system with no or unmapped LPC bus. Unable to handle kernel paging request at virtual address ffffffbffee0002e pgd = ffffffc1d68d4000 [ffffffbffee0002e] *pgd=0000000000000000, *pud=0000000000000000 Internal error: Oops: 94000046 [#1] PREEMPT SMP Modules linked in: f71805f(+) hwmon CPU: 3 PID: 1659 Comm: insmod Not tainted 4.5.0+ #88 Hardware name: linux,dummy-virt (DT) task: ffffffc1f6665400 ti: ffffffc1d6418000 task.ti: ffffffc1d6418000 PC is at f71805f_find+0x6c/0x358 [f71805f] 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: e53004e ("hwmon: New f71805f 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]>
1 parent df6b8c7 commit 73e6ff7

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

drivers/hwmon/f71805f.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,23 @@ superio_select(int base, int ld)
9696
outb(ld, base + 1);
9797
}
9898

99-
static inline void
99+
static inline int
100100
superio_enter(int base)
101101
{
102+
if (!request_muxed_region(base, 2, DRVNAME))
103+
return -EBUSY;
104+
102105
outb(0x87, base);
103106
outb(0x87, base);
107+
108+
return 0;
104109
}
105110

106111
static inline void
107112
superio_exit(int base)
108113
{
109114
outb(0xaa, base);
115+
release_region(base, 2);
110116
}
111117

112118
/*
@@ -1561,16 +1567,19 @@ static int __init f71805f_device_add(unsigned short address,
15611567
static int __init f71805f_find(int sioaddr, unsigned short *address,
15621568
struct f71805f_sio_data *sio_data)
15631569
{
1564-
int err = -ENODEV;
1570+
int err;
15651571
u16 devid;
15661572

15671573
static const char * const names[] = {
15681574
"F71805F/FG",
15691575
"F71872F/FG or F71806F/FG",
15701576
};
15711577

1572-
superio_enter(sioaddr);
1578+
err = superio_enter(sioaddr);
1579+
if (err)
1580+
return err;
15731581

1582+
err = -ENODEV;
15741583
devid = superio_inw(sioaddr, SIO_REG_MANID);
15751584
if (devid != SIO_FINTEK_ID)
15761585
goto exit;

0 commit comments

Comments
 (0)