]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
cm4000_cs: fix error paths
authorAkinobu Mita <akinobu.mita@gmail.com>
Wed, 9 May 2007 09:33:31 +0000 (02:33 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Wed, 9 May 2007 19:30:49 +0000 (12:30 -0700)
This patch fixes error paths in module_init and probe functions in cm4000_cs
and cm4040_cs drivers.

Cc: Harald Welte <laforge@gnumonks.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/char/pcmcia/cm4000_cs.c
drivers/char/pcmcia/cm4040_cs.c

index e91b43a014b09edf096ce80e8d40ec2f1fee4880..8cbc64fe0feb79709e671cba1e6c0e00a86f6a89 100644 (file)
@@ -1881,8 +1881,11 @@ static int cm4000_probe(struct pcmcia_device *link)
        init_waitqueue_head(&dev->readq);
 
        ret = cm4000_config(link, i);
-       if (ret)
+       if (ret) {
+               dev_table[i] = NULL;
+               kfree(dev);
                return ret;
+       }
 
        class_device_create(cmm_class, NULL, MKDEV(major, i), NULL,
                            "cmm%d", i);
@@ -1907,7 +1910,7 @@ static void cm4000_detach(struct pcmcia_device *link)
        cm4000_release(link);
 
        dev_table[devno] = NULL;
-       kfree(dev);
+       kfree(dev);
 
        class_device_destroy(cmm_class, MKDEV(major, devno));
 
@@ -1956,12 +1959,14 @@ static int __init cmm_init(void)
        if (major < 0) {
                printk(KERN_WARNING MODULE_NAME
                        ": could not get major number\n");
+               class_destroy(cmm_class);
                return major;
        }
 
        rc = pcmcia_register_driver(&cm4000_driver);
        if (rc < 0) {
                unregister_chrdev(major, DEVICE_NAME);
+               class_destroy(cmm_class);
                return rc;
        }
 
index f2e4ec4fd407968b7322dac8664b5fdcb6fff9e0..af88181a17f477cd01e5a1f2644a9c8039619262 100644 (file)
@@ -636,8 +636,11 @@ static int reader_probe(struct pcmcia_device *link)
        setup_timer(&dev->poll_timer, cm4040_do_poll, 0);
 
        ret = reader_config(link, i);
-       if (ret)
+       if (ret) {
+               dev_table[i] = NULL;
+               kfree(dev);
                return ret;
+       }
 
        class_device_create(cmx_class, NULL, MKDEV(major, i), NULL,
                            "cmx%d", i);
@@ -708,12 +711,14 @@ static int __init cm4040_init(void)
        if (major < 0) {
                printk(KERN_WARNING MODULE_NAME
                        ": could not get major number\n");
+               class_destroy(cmx_class);
                return major;
        }
 
        rc = pcmcia_register_driver(&reader_driver);
        if (rc < 0) {
                unregister_chrdev(major, DEVICE_NAME);
+               class_destroy(cmx_class);
                return rc;
        }