isdn/gigaset/common.c: fix a memory leak
PATCH 1/1 isdn/gigaset/common.c: fix a memory leak
This patch fixes a memory leak spotted by the Coverity checker if (!try_module_get(owner)).
Signed-off-by Adrian Bunk <[email protected]>
---
drivers/isdn/gigaset/common.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/isdn/gigaset/common.c renamed from drivers/isdn/gigaset/common.c.old +8 -5
@@ -1110,8 +1110,9 @@ struct gigaset_driver *gigaset_initdrive drv =kmalloc (sizeof *drv,GFP_KERNEL );if (!drv)return NULL ; +if (!try_module_get (owner)) -return NULL ; + goto out1; drv->cs =NULL ; drv->have_tty =0 ;
@@ -1125,10 +1126,11 @@ struct gigaset_driver *gigaset_initdrive drv->cs =kmalloc (minors *sizeof *drv->cs,GFP_KERNEL );if (!drv->cs) - goto out1; + goto out2; + drv->flags =kmalloc (minors *sizeof *drv->flags,GFP_KERNEL );if (!drv->flags) - goto out2; + goto out3;for (i =0 ; i < minors; ++i) { drv->flags[i] =0 ;
@@ -1145,11 +1147,12 @@ struct gigaset_driver *gigaset_initdrivereturn drv; -out2: +out3:kfree (drv->cs); +out2: +module_put (owner); out1:kfree (drv); -module_put (owner);return NULL ; }EXPORT_SYMBOL_GPL (gigaset_initdriver);
Quoted 2 lines · Adrian Bunk
This patch fixes a memory leak spotted by the Coverity checker if (!try_module_get(owner)).
Good catch. Thanks.
Quoted 1 line
Signed-off-by Adrian Bunk <[email protected]>
Acked-by Tilman Schmidt <[email protected]>
Quoted 39 lines
---
drivers/isdn/gigaset/common.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)drivers/isdn/gigaset/common.c renamed from drivers/isdn/gigaset/common.c.old +5
-4@@ -1110,8 +1110,9 @@ struct gigaset_driver *gigaset_initdrive drv =kmalloc (sizeof *drv,GFP_KERNEL );if (!drv)return NULL ; +if (!try_module_get (owner)) -return NULL ; + goto out1; drv->cs =NULL ; drv->have_tty =0 ;@@ -1125,10 +1126,11 @@ struct gigaset_driver *gigaset_initdrive drv->cs =kmalloc (minors *sizeof *drv->cs,GFP_KERNEL );if (!drv->cs) - goto out1; + goto out2; + drv->flags =kmalloc (minors *sizeof *drv->flags,GFP_KERNEL );if (!drv->flags) - goto out2; + goto out3;for (i =0 ; i < minors; ++i) { drv->flags[i] =0 ;@@ -1145,11 +1147,12 @@ struct gigaset_driver *gigaset_initdrivereturn drv; -out2:
drivers/isdn/gigaset/common.c struct gigaset_driver *gigaset_initdrive · line 1158
Quoted 10 lines
drivers/isdn/gigaset/common.c renamed from drivers/isdn/gigaset/common.c.old +3
-1+out3:kfree (drv->cs); +out2: +module_put (owner); out1:kfree (drv); -module_put (owner);return NULL ; }EXPORT_SYMBOL_GPL (gigaset_initdriver);
--
Tilman Schmidt E-Mail: [email protected]
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits. Ungeöffnet mindestens haltbar bis: (siehe Rückseite)