Commit 5eb5fc97 authored by Akinobu Mita's avatar Akinobu Mita Committed by Dominik Brodowski

[PATCH] cm4000_cs: fix return value check

The return value of class_create() need to be checked with IS_ERR().
And register_chrdev() returns errno on failure.
This patch includes these fixes for cm4000_cs and cm4040_cs.
Signed-off-by: default avatarAkinbou Mita <akinobu.mita@gmail.com>
Signed-off-by: default avatarHarald Welte <laforge@gnumonks.org>
Signed-off-by: default avatarDominik Brodowski <linux@dominikbrodowski.net>
parent 0517793f
...@@ -1973,14 +1973,14 @@ static int __init cmm_init(void) ...@@ -1973,14 +1973,14 @@ static int __init cmm_init(void)
printk(KERN_INFO "%s\n", version); printk(KERN_INFO "%s\n", version);
cmm_class = class_create(THIS_MODULE, "cardman_4000"); cmm_class = class_create(THIS_MODULE, "cardman_4000");
if (!cmm_class) if (IS_ERR(cmm_class))
return -1; return PTR_ERR(cmm_class);
major = register_chrdev(0, DEVICE_NAME, &cm4000_fops); major = register_chrdev(0, DEVICE_NAME, &cm4000_fops);
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");
return -1; return major;
} }
rc = pcmcia_register_driver(&cm4000_driver); rc = pcmcia_register_driver(&cm4000_driver);
......
...@@ -721,14 +721,14 @@ static int __init cm4040_init(void) ...@@ -721,14 +721,14 @@ static int __init cm4040_init(void)
printk(KERN_INFO "%s\n", version); printk(KERN_INFO "%s\n", version);
cmx_class = class_create(THIS_MODULE, "cardman_4040"); cmx_class = class_create(THIS_MODULE, "cardman_4040");
if (!cmx_class) if (IS_ERR(cmx_class))
return -1; return PTR_ERR(cmx_class);
major = register_chrdev(0, DEVICE_NAME, &reader_fops); major = register_chrdev(0, DEVICE_NAME, &reader_fops);
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");
return -1; return major;
} }
rc = pcmcia_register_driver(&reader_driver); rc = pcmcia_register_driver(&reader_driver);
......
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