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 <devendra.aaru@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Devendra Naga 2012-09-13 13:08:48 -04:00 committed by Greg Kroah-Hartman
parent 43bf2f4bfe
commit 99d4b1a6cb
1 changed files with 3 additions and 1 deletions

View File

@ -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);