diff options
author | Alexey Dobriyan <adobriyan@gmail.com> | 2007-03-24 15:58:12 +0300 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2007-03-26 20:26:11 +0000 |
commit | fb8f7ba077b5c665432082ab205bcd2cb01f6a3c (patch) | |
tree | 13a956eb9a1723bd3d5463230acbfc6513f3b034 /drivers/char/watchdog/eurotechwdt.c | |
parent | 0e94f2ee0d1947ba6c2c00c3e971ff93ce8edec1 (diff) | |
download | lwn-fb8f7ba077b5c665432082ab205bcd2cb01f6a3c.tar.gz lwn-fb8f7ba077b5c665432082ab205bcd2cb01f6a3c.zip |
[WATCHDOG] Semi-typical watchdog bug re early misc_register()
It seems that some watchdog drivers are doing following mistake:
rv = misc_register();
if (rv < 0)
return rv;
rv = request_region();
if (rv < 0) {
misc_deregister();
return rv;
}
But, right after misc_register() returns, misc device can be opened and
ioctls interacting with hardware issued, and driver can do outb() to
port it doesn't own yet, because request_region() is still pending.
Here is my patch, compile-tested only.
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/char/watchdog/eurotechwdt.c')
-rw-r--r-- | drivers/char/watchdog/eurotechwdt.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/drivers/char/watchdog/eurotechwdt.c b/drivers/char/watchdog/eurotechwdt.c index f70387f01b2b..b070324e27a6 100644 --- a/drivers/char/watchdog/eurotechwdt.c +++ b/drivers/char/watchdog/eurotechwdt.c @@ -413,17 +413,10 @@ static int __init eurwdt_init(void) { int ret; - ret = misc_register(&eurwdt_miscdev); - if (ret) { - printk(KERN_ERR "eurwdt: can't misc_register on minor=%d\n", - WATCHDOG_MINOR); - goto out; - } - ret = request_irq(irq, eurwdt_interrupt, IRQF_DISABLED, "eurwdt", NULL); if(ret) { printk(KERN_ERR "eurwdt: IRQ %d is not free.\n", irq); - goto outmisc; + goto out; } if (!request_region(io, 2, "eurwdt")) { @@ -438,6 +431,13 @@ static int __init eurwdt_init(void) goto outreg; } + ret = misc_register(&eurwdt_miscdev); + if (ret) { + printk(KERN_ERR "eurwdt: can't misc_register on minor=%d\n", + WATCHDOG_MINOR); + goto outreboot; + } + eurwdt_unlock_chip(); ret = 0; @@ -448,14 +448,14 @@ static int __init eurwdt_init(void) out: return ret; +outreboot: + unregister_reboot_notifier(&eurwdt_notifier); + outreg: release_region(io, 2); outirq: free_irq(irq, NULL); - -outmisc: - misc_deregister(&eurwdt_miscdev); goto out; } |