diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2007-05-08 03:29:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-08 14:15:09 -0400 |
commit | b2bbe383ef7e792e92a5f53be955e71bd253ab32 (patch) | |
tree | 8ca8e4ee8155c6adb6023ecf78b9e9421a7e341d /drivers/char | |
parent | 19d0e8ce856a7628a630710aed82931ce1c7eb97 (diff) |
dtlk: fix error checks in module_init()
This patch fixes two things in module_init.
- fix register_chrdev() error check
Currently dtlk doesn't check register_chrdev() failure correctly.
register_chrdev() returns a errno on failure.
- check probe failure
dtlk ignores probe failure and allows the module loading without
such device. I got "Trying to free nonexistent resource" message
by release_region() when unloading module without device.
[akpm@linux-foundation.org: fix error code return]
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Chris Pallotta <chris@allmedia.com>
Cc: Jim Van Zandt <jrv@vanzandt.mv.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/dtlk.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/char/dtlk.c b/drivers/char/dtlk.c index 9695f88badc6..abde6ddefe69 100644 --- a/drivers/char/dtlk.c +++ b/drivers/char/dtlk.c | |||
@@ -324,16 +324,22 @@ static int dtlk_release(struct inode *inode, struct file *file) | |||
324 | 324 | ||
325 | static int __init dtlk_init(void) | 325 | static int __init dtlk_init(void) |
326 | { | 326 | { |
327 | int err; | ||
328 | |||
327 | dtlk_port_lpc = 0; | 329 | dtlk_port_lpc = 0; |
328 | dtlk_port_tts = 0; | 330 | dtlk_port_tts = 0; |
329 | dtlk_busy = 0; | 331 | dtlk_busy = 0; |
330 | dtlk_major = register_chrdev(0, "dtlk", &dtlk_fops); | 332 | dtlk_major = register_chrdev(0, "dtlk", &dtlk_fops); |
331 | if (dtlk_major == 0) { | 333 | if (dtlk_major < 0) { |
332 | printk(KERN_ERR "DoubleTalk PC - cannot register device\n"); | 334 | printk(KERN_ERR "DoubleTalk PC - cannot register device\n"); |
333 | return 0; | 335 | return dtlk_major; |
336 | } | ||
337 | err = dtlk_dev_probe(); | ||
338 | if (err) { | ||
339 | unregister_chrdev(dtlk_major, "dtlk"); | ||
340 | return err; | ||
334 | } | 341 | } |
335 | if (dtlk_dev_probe() == 0) | 342 | printk(", MAJOR %d\n", dtlk_major); |
336 | printk(", MAJOR %d\n", dtlk_major); | ||
337 | 343 | ||
338 | init_waitqueue_head(&dtlk_process_list); | 344 | init_waitqueue_head(&dtlk_process_list); |
339 | 345 | ||