Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b2bbe383ef7e792e92a5f53be955e71bd253ab32
Commit:     b2bbe383ef7e792e92a5f53be955e71bd253ab32
Parent:     19d0e8ce856a7628a630710aed82931ce1c7eb97
Author:     Akinobu Mita <[EMAIL PROTECTED]>
AuthorDate: Tue May 8 00:29:18 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Tue May 8 11:15:09 2007 -0700

    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.
    
    [EMAIL PROTECTED]: fix error code return]
    Signed-off-by: Akinobu Mita <[EMAIL PROTECTED]>
    Cc: Chris Pallotta <[EMAIL PROTECTED]>
    Cc: Jim Van Zandt <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 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 9695f88..abde6dd 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)
 
 static int __init dtlk_init(void)
 {
+       int err;
+
        dtlk_port_lpc = 0;
        dtlk_port_tts = 0;
        dtlk_busy = 0;
        dtlk_major = register_chrdev(0, "dtlk", &dtlk_fops);
-       if (dtlk_major == 0) {
+       if (dtlk_major < 0) {
                printk(KERN_ERR "DoubleTalk PC - cannot register device\n");
-               return 0;
+               return dtlk_major;
+       }
+       err = dtlk_dev_probe();
+       if (err) {
+               unregister_chrdev(dtlk_major, "dtlk");
+               return err;
        }
-       if (dtlk_dev_probe() == 0)
-               printk(", MAJOR %d\n", dtlk_major);
+       printk(", MAJOR %d\n", dtlk_major);
 
        init_waitqueue_head(&dtlk_process_list);
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to