From: Zhouyi Zhou Date: Wed, 10 Aug 2016 08:06:43 +0000 (+0800) Subject: snsc: check return value of class_create X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=c1e8ad231141be21471d2cc624773eb5250c07b3;p=openwrt%2Fstaging%2Fblogic.git snsc: check return value of class_create return value of class_create should be considered in module init function. Signed-off-by: Zhouyi Zhou Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/char/snsc.c b/drivers/char/snsc.c index 94006f9c2e43..10e56323f390 100644 --- a/drivers/char/snsc.c +++ b/drivers/char/snsc.c @@ -385,13 +385,18 @@ scdrv_init(void) event_nasid = ia64_sn_get_console_nasid(); + snsc_class = class_create(THIS_MODULE, SYSCTL_BASENAME); + if (IS_ERR(snsc_class)) { + printk("%s: failed to allocate class\n", __func__); + return PTR_ERR(snsc_class); + } + if (alloc_chrdev_region(&first_dev, 0, num_cnodes, SYSCTL_BASENAME) < 0) { printk("%s: failed to register SN system controller device\n", __func__); return -ENODEV; } - snsc_class = class_create(THIS_MODULE, SYSCTL_BASENAME); for (cnode = 0; cnode < num_cnodes; cnode++) { geoid = cnodeid_get_geoid(cnode);