Skip to content

Commit

Permalink
staging:ccg: fix a class_destroy when kmalloc fails after the class_c…
Browse files Browse the repository at this point in the history
…reate

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>
  • Loading branch information
Devendra Naga authored and Greg Kroah-Hartman committed Sep 14, 2012
1 parent 43bf2f4 commit 99d4b1a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/staging/ccg/ccg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 99d4b1a

Please sign in to comment.