From: David Miller <davem@davemloft.net>
To: tilman@imap.cc
Cc: jj@chaosbits.net, gigaset307x-common@lists.sourceforge.net,
hjlipp@web.de, 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: Fri, 31 Dec 2010 11:21:01 -0800 (PST) [thread overview]
Message-ID: <20101231.112101.70194518.davem@davemloft.net> (raw)
In-Reply-To: <4D1A2185.2010700@imap.cc>
From: Tilman Schmidt <tilman@imap.cc>
Date: Tue, 28 Dec 2010 18:42:29 +0100
> 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>
Applied.
prev parent reply other threads:[~2010-12-31 19:21 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
2010-12-31 19:21 ` David Miller [this message]
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=20101231.112101.70194518.davem@davemloft.net \
--to=davem@davemloft.net \
--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 \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).