Commit f4675c70 authored by Adrian Bunk's avatar Adrian Bunk Committed by Linus Torvalds

[PATCH] isdn/gigaset/common.c: fix a memory leak

Fix a memory leak spotted by the Coverity checker if
(!try_module_get(owner)).
Signed-off-by: default avatarAdrian Bunk <bunk@stusta.de>
Acked-by: default avatarTilman Schmidt <tilman@imap.cc>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 8ca445df
...@@ -1110,8 +1110,9 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors, ...@@ -1110,8 +1110,9 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
drv = kmalloc(sizeof *drv, GFP_KERNEL); drv = kmalloc(sizeof *drv, GFP_KERNEL);
if (!drv) if (!drv)
return NULL; return NULL;
if (!try_module_get(owner)) if (!try_module_get(owner))
return NULL; goto out1;
drv->cs = NULL; drv->cs = NULL;
drv->have_tty = 0; drv->have_tty = 0;
...@@ -1125,10 +1126,11 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors, ...@@ -1125,10 +1126,11 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
drv->cs = kmalloc(minors * sizeof *drv->cs, GFP_KERNEL); drv->cs = kmalloc(minors * sizeof *drv->cs, GFP_KERNEL);
if (!drv->cs) if (!drv->cs)
goto out1; goto out2;
drv->flags = kmalloc(minors * sizeof *drv->flags, GFP_KERNEL); drv->flags = kmalloc(minors * sizeof *drv->flags, GFP_KERNEL);
if (!drv->flags) if (!drv->flags)
goto out2; goto out3;
for (i = 0; i < minors; ++i) { for (i = 0; i < minors; ++i) {
drv->flags[i] = 0; drv->flags[i] = 0;
...@@ -1145,11 +1147,12 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors, ...@@ -1145,11 +1147,12 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
return drv; return drv;
out2: out3:
kfree(drv->cs); kfree(drv->cs);
out2:
module_put(owner);
out1: out1:
kfree(drv); kfree(drv);
module_put(owner);
return NULL; return NULL;
} }
EXPORT_SYMBOL_GPL(gigaset_initdriver); EXPORT_SYMBOL_GPL(gigaset_initdriver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment