From: Anton Protopopov Date: Wed, 9 Jul 2014 05:12:37 +0000 (+0400) Subject: Staging: comedi: check the return value of kobject_set_name X-Git-Tag: firefly_0821_release~176^2~3491^2~1111 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=a5bde3a163cc4701e693c7c1d9cb9d6c9b888c75;p=firefly-linux-kernel-4.4.55.git Staging: comedi: check the return value of kobject_set_name Added a check of the return value of the kobject_set_name function. Signed-off-by: Anton Protopopov Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c index e8e38098dcf8..038b69a93185 100644 --- a/drivers/staging/comedi/comedi_fops.c +++ b/drivers/staging/comedi/comedi_fops.c @@ -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);