summaryrefslogtreecommitdiff
path: root/drivers/char/watchdog/ibmasr.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/ibmasr.c
parent0e94f2ee0d1947ba6c2c00c3e971ff93ce8edec1 (diff)
downloadlwn-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/ibmasr.c')
-rw-r--r--drivers/char/watchdog/ibmasr.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/char/watchdog/ibmasr.c b/drivers/char/watchdog/ibmasr.c
index 8195f5023d85..94155f6136c2 100644
--- a/drivers/char/watchdog/ibmasr.c
+++ b/drivers/char/watchdog/ibmasr.c
@@ -367,18 +367,17 @@ static int __init ibmasr_init(void)
if (!asr_type)
return -ENODEV;
+ rc = asr_get_base_address();
+ if (rc)
+ return rc;
+
rc = misc_register(&asr_miscdev);
if (rc < 0) {
+ release_region(asr_base, asr_length);
printk(KERN_ERR PFX "failed to register misc device\n");
return rc;
}
- rc = asr_get_base_address();
- if (rc) {
- misc_deregister(&asr_miscdev);
- return rc;
- }
-
return 0;
}