From: Devendra Naga Date: Thu, 13 Sep 2012 17:08:48 +0000 (-0400) Subject: staging:ccg: fix a class_destroy when kmalloc fails after the class_create X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=99d4b1a6cbfa8449dad5fb58e8c8044301e2667a;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git staging:ccg: fix a class_destroy when kmalloc fails after the class_create we do class_create and call kmalloc to allocate dev pointer, and if kmalloc fail we forget destoying class Signed-off-by: Devendra Naga Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/ccg/ccg.c b/drivers/staging/ccg/ccg.c index 81ac6bbba55f..565249b2d755 100644 --- a/drivers/staging/ccg/ccg.c +++ b/drivers/staging/ccg/ccg.c @@ -1254,8 +1254,10 @@ static int __init init(void) return PTR_ERR(ccg_class); dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) + if (!dev) { + class_destroy(ccg_class); return -ENOMEM; + } dev->functions = supported_functions; INIT_LIST_HEAD(&dev->enabled_functions);