From: Adrian Bunk <bunk@stusta.de>
To: hjlipp@web.de, tilman@imap.cc
Cc: gigaset307x-common@lists.sourceforge.net, kkeil@suse.de,
isdn4linux@listserv.isdn4linux.de, linux-kernel@vger.kernel.org
Subject: [2.6 patch] isdn/gigaset/common.c: fix a memory leak
Date: Tue, 4 Apr 2006 21:00:02 +0200 [thread overview]
Message-ID: <20060404190002.GZ6529@stusta.de> (raw)
This patch fixes a memory leak spotted by the Coverity checker
if (!try_module_get(owner)).
Signed-off-by: Adrian Bunk <bunk@stusta.de>
---
drivers/isdn/gigaset/common.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
--- linux-2.6.17-rc1-mm1-full/drivers/isdn/gigaset/common.c.old 2006-04-04 19:45:19.000000000 +0200
+++ linux-2.6.17-rc1-mm1-full/drivers/isdn/gigaset/common.c 2006-04-04 19:51:23.000000000 +0200
@@ -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_initdrive
return drv;
-out2:
+out3:
kfree(drv->cs);
+out2:
+ module_put(owner);
out1:
kfree(drv);
- module_put(owner);
return NULL;
}
EXPORT_SYMBOL_GPL(gigaset_initdriver);
next reply other threads:[~2006-04-04 19:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-04-04 19:00 Adrian Bunk [this message]
2006-04-05 9:39 ` [2.6 patch] isdn/gigaset/common.c: fix a memory leak Tilman Schmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060404190002.GZ6529@stusta.de \
--to=bunk@stusta.de \
--cc=gigaset307x-common@lists.sourceforge.net \
--cc=hjlipp@web.de \
--cc=isdn4linux@listserv.isdn4linux.de \
--cc=kkeil@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=tilman@imap.cc \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.