From 99d4b1a6cbfa8449dad5fb58e8c8044301e2667a Mon Sep 17 00:00:00 2001 From: Devendra Naga Date: Thu, 13 Sep 2012 13:08:48 -0400 Subject: [PATCH] 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 --- drivers/staging/ccg/ccg.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); -- 2.39.5