From: Tilman Schmidt <tilman@imap.cc>
To: Jesper Juhl <jj@chaosbits.net>
Cc: gigaset307x-common@lists.sourceforge.net,
Hansjoerg Lipp <hjlipp@web.de>,
Karsten Keil <isdn@linux-pingi.de>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ISDN, Gigaset: Fix memory leak in do_disconnect_req()
Date: Tue, 28 Dec 2010 18:42:29 +0100 [thread overview]
Message-ID: <4D1A2185.2010700@imap.cc> (raw)
In-Reply-To: <alpine.LNX.2.00.1012262053130.20797@swampdragon.chaosbits.net>
[-- Attachment #1: Type: text/plain, Size: 2022 bytes --]
Quite correct. Thanks for finding and fixing this.
Am 26.12.2010 20:59 schrieb Jesper Juhl:
> Hi,
>
> In drivers/isdn/gigaset/capi.c::do_disconnect_req() we will leak the
> memory allocated (with kmalloc) to 'b3cmsg' if the call to alloc_skb()
> fails.
>
> ...
> b3cmsg = kmalloc(sizeof(*b3cmsg), GFP_KERNEL);
> allocation here ------^
> if (!b3cmsg) {
> dev_err(cs->dev, "%s: out of memory\n", __func__);
> send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR);
> return;
> }
> capi_cmsg_header(b3cmsg, ap->id, CAPI_DISCONNECT_B3, CAPI_IND,
> ap->nextMessageNumber++,
> cmsg->adr.adrPLCI | (1 << 16));
> b3cmsg->Reason_B3 = CapiProtocolErrorLayer1;
> b3skb = alloc_skb(CAPI_DISCONNECT_B3_IND_BASELEN, GFP_KERNEL);
> if (b3skb == NULL) {
> dev_err(cs->dev, "%s: out of memory\n", __func__);
> send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR);
> return;
> leak here ------^
> ...
>
> This leak is easily fixed by just kfree()'ing the memory allocated to
> 'b3cmsg' right before we return. The following patch does that.
>
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Acked-by: Tilman Schmidt <tilman@imap.cc>
> ---
> capi.c | 1 +
> 1 file changed, 1 insertion(+)
>
> compile tested only since I have no way to actually test this.
>
> diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c
> index bcc174e..658e75f 100644
> --- a/drivers/isdn/gigaset/capi.c
> +++ b/drivers/isdn/gigaset/capi.c
> @@ -1900,6 +1900,7 @@ static void do_disconnect_req(struct gigaset_capi_ctr *iif,
> if (b3skb == NULL) {
> dev_err(cs->dev, "%s: out of memory\n", __func__);
> send_conf(iif, ap, skb, CAPI_MSGOSRESOURCEERR);
> + kfree(b3cmsg);
> return;
> }
> capi_cmsg2message(b3cmsg,
>
>
--
Tilman Schmidt E-Mail: tilman@imap.cc
Bonn, Germany
Diese Nachricht besteht zu 100% aus wiederverwerteten Bits.
Ungeöffnet mindestens haltbar bis: (siehe Rückseite)
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 259 bytes --]
next prev parent reply other threads:[~2010-12-28 17:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-26 19:59 [PATCH] ISDN, Gigaset: Fix memory leak in do_disconnect_req() Jesper Juhl
2010-12-28 17:42 ` Tilman Schmidt [this message]
2010-12-31 19:21 ` David Miller
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=4D1A2185.2010700@imap.cc \
--to=tilman@imap.cc \
--cc=gigaset307x-common@lists.sourceforge.net \
--cc=hjlipp@web.de \
--cc=isdn@linux-pingi.de \
--cc=jj@chaosbits.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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.