Commit 54493c10 authored by Akinobu Mita's avatar Akinobu Mita Committed by Linus Torvalds

cm4000_cs: fix error paths

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: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Cc: Dominik Brodowski <linux@dominikbrodowski.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 8813d1c0
...@@ -1881,8 +1881,11 @@ static int cm4000_probe(struct pcmcia_device *link) ...@@ -1881,8 +1881,11 @@ static int cm4000_probe(struct pcmcia_device *link)
init_waitqueue_head(&dev->readq); init_waitqueue_head(&dev->readq);
ret = cm4000_config(link, i); ret = cm4000_config(link, i);
if (ret) if (ret) {
dev_table[i] = NULL;
kfree(dev);
return ret; return ret;
}
class_device_create(cmm_class, NULL, MKDEV(major, i), NULL, class_device_create(cmm_class, NULL, MKDEV(major, i), NULL,
"cmm%d", i); "cmm%d", i);
...@@ -1956,12 +1959,14 @@ static int __init cmm_init(void) ...@@ -1956,12 +1959,14 @@ static int __init cmm_init(void)
if (major < 0) { if (major < 0) {
printk(KERN_WARNING MODULE_NAME printk(KERN_WARNING MODULE_NAME
": could not get major number\n"); ": could not get major number\n");
class_destroy(cmm_class);
return major; return major;
} }
rc = pcmcia_register_driver(&cm4000_driver); rc = pcmcia_register_driver(&cm4000_driver);
if (rc < 0) { if (rc < 0) {
unregister_chrdev(major, DEVICE_NAME); unregister_chrdev(major, DEVICE_NAME);
class_destroy(cmm_class);
return rc; return rc;
} }
......
...@@ -636,8 +636,11 @@ static int reader_probe(struct pcmcia_device *link) ...@@ -636,8 +636,11 @@ static int reader_probe(struct pcmcia_device *link)
setup_timer(&dev->poll_timer, cm4040_do_poll, 0); setup_timer(&dev->poll_timer, cm4040_do_poll, 0);
ret = reader_config(link, i); ret = reader_config(link, i);
if (ret) if (ret) {
dev_table[i] = NULL;
kfree(dev);
return ret; return ret;
}
class_device_create(cmx_class, NULL, MKDEV(major, i), NULL, class_device_create(cmx_class, NULL, MKDEV(major, i), NULL,
"cmx%d", i); "cmx%d", i);
...@@ -708,12 +711,14 @@ static int __init cm4040_init(void) ...@@ -708,12 +711,14 @@ static int __init cm4040_init(void)
if (major < 0) { if (major < 0) {
printk(KERN_WARNING MODULE_NAME printk(KERN_WARNING MODULE_NAME
": could not get major number\n"); ": could not get major number\n");
class_destroy(cmx_class);
return major; return major;
} }
rc = pcmcia_register_driver(&reader_driver); rc = pcmcia_register_driver(&reader_driver);
if (rc < 0) { if (rc < 0) {
unregister_chrdev(major, DEVICE_NAME); unregister_chrdev(major, DEVICE_NAME);
class_destroy(cmx_class);
return rc; return rc;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment