[PATCH] cm4000_cs: fix return value check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Cc: Harald Welte <[email protected]>
Signed-off-by: Akinbou Mita <[email protected]>

 drivers/char/pcmcia/cm4000_cs.c |    6 +++---
 drivers/char/pcmcia/cm4040_cs.c |    6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

Index: 2.6-rc/drivers/char/pcmcia/cm4000_cs.c
===================================================================
--- 2.6-rc.orig/drivers/char/pcmcia/cm4000_cs.c
+++ 2.6-rc/drivers/char/pcmcia/cm4000_cs.c
@@ -1973,14 +1973,14 @@ static int __init cmm_init(void)
 	printk(KERN_INFO "%s\n", version);
 
 	cmm_class = class_create(THIS_MODULE, "cardman_4000");
-	if (!cmm_class)
-		return -1;
+	if (IS_ERR(cmm_class))
+		return PTR_ERR(cmm_class);
 
 	major = register_chrdev(0, DEVICE_NAME, &cm4000_fops);
 	if (major < 0) {
 		printk(KERN_WARNING MODULE_NAME
 			": could not get major number\n");
-		return -1;
+		return major;
 	}
 
 	rc = pcmcia_register_driver(&cm4000_driver);
Index: 2.6-rc/drivers/char/pcmcia/cm4040_cs.c
===================================================================
--- 2.6-rc.orig/drivers/char/pcmcia/cm4040_cs.c
+++ 2.6-rc/drivers/char/pcmcia/cm4040_cs.c
@@ -721,14 +721,14 @@ static int __init cm4040_init(void)
 
 	printk(KERN_INFO "%s\n", version);
 	cmx_class = class_create(THIS_MODULE, "cardman_4040");
-	if (!cmx_class)
-		return -1;
+	if (IS_ERR(cmx_class))
+		return PTR_ERR(cmx_class);
 
 	major = register_chrdev(0, DEVICE_NAME, &reader_fops);
 	if (major < 0) {
 		printk(KERN_WARNING MODULE_NAME
 			": could not get major number\n");
-		return -1;
+		return major;
 	}
 
 	rc = pcmcia_register_driver(&reader_driver);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux