Staging: comedi: check the return value of kobject_set_name
authorAnton Protopopov <a.s.protopopov@gmail.com>
Wed, 9 Jul 2014 05:12:37 +0000 (09:12 +0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 9 Jul 2014 19:19:36 +0000 (12:19 -0700)
Added a check of the return value of the kobject_set_name function.

Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/comedi/comedi_fops.c

index e8e38098dcf85578eee062690511f85526b657d5..038b69a931856a49021cbbf25f6dcefffb346734 100644 (file)
@@ -2587,7 +2587,14 @@ static int __init comedi_init(void)
                return -EIO;
        cdev_init(&comedi_cdev, &comedi_fops);
        comedi_cdev.owner = THIS_MODULE;
-       kobject_set_name(&comedi_cdev.kobj, "comedi");
+
+       retval = kobject_set_name(&comedi_cdev.kobj, "comedi");
+       if (retval) {
+               unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
+                                        COMEDI_NUM_MINORS);
+               return retval;
+       }
+
        if (cdev_add(&comedi_cdev, MKDEV(COMEDI_MAJOR, 0), COMEDI_NUM_MINORS)) {
                unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
                                         COMEDI_NUM_MINORS);