summaryrefslogtreecommitdiff
path: root/drivers/char/watchdog/machzwd.c
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2007-03-24 15:58:12 +0300
committerWim Van Sebroeck <wim@iguana.be>2007-03-26 20:26:11 +0000
commitfb8f7ba077b5c665432082ab205bcd2cb01f6a3c (patch)
tree13a956eb9a1723bd3d5463230acbfc6513f3b034 /drivers/char/watchdog/machzwd.c
parent0e94f2ee0d1947ba6c2c00c3e971ff93ce8edec1 (diff)
[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/machzwd.c')
-rw-r--r--drivers/char/watchdog/machzwd.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/drivers/char/watchdog/machzwd.c b/drivers/char/watchdog/machzwd.c
index 76c7fa37fa6c..a0d27160c80e 100644
--- a/drivers/char/watchdog/machzwd.c
+++ b/drivers/char/watchdog/machzwd.c
@@ -440,13 +440,6 @@ static int __init zf_init(void)
spin_lock_init(&zf_lock);
spin_lock_init(&zf_port_lock);
- ret = misc_register(&zf_miscdev);
- if (ret){
- printk(KERN_ERR "can't misc_register on minor=%d\n",
- WATCHDOG_MINOR);
- goto out;
- }
-
if(!request_region(ZF_IOBASE, 3, "MachZ ZFL WDT")){
printk(KERN_ERR "cannot reserve I/O ports at %d\n",
ZF_IOBASE);
@@ -461,16 +454,23 @@ static int __init zf_init(void)
goto no_reboot;
}
+ ret = misc_register(&zf_miscdev);
+ if (ret){
+ printk(KERN_ERR "can't misc_register on minor=%d\n",
+ WATCHDOG_MINOR);
+ goto no_misc;
+ }
+
zf_set_status(0);
zf_set_control(0);
return 0;
+no_misc:
+ unregister_reboot_notifier(&zf_notifier);
no_reboot:
release_region(ZF_IOBASE, 3);
no_region:
- misc_deregister(&zf_miscdev);
-out:
return ret;
}