netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: eilong@broadcom.com
Cc: jj@chaosbits.net, eric.dumazet@gmail.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, eliezert@broadcom.com
Subject: Re: [PATCH] bnx2x: Fix mem leak in bnx2x_tpa_stop() if build_skb() fails.
Date: Tue, 07 Feb 2012 13:14:13 -0500 (EST)	[thread overview]
Message-ID: <20120207.131413.1550725807432901999.davem@davemloft.net> (raw)
In-Reply-To: <1328597701.18349.0.camel@lb-tlvb-eilong.il.broadcom.com>

From: "Eilon Greenstein" <eilong@broadcom.com>
Date: Tue, 7 Feb 2012 08:55:01 +0200

> On Mon, 2012-02-06 at 23:53 +0100, Eric Dumazet wrote:
>> Le lundi 06 février 2012 à 22:28 +0100, Jesper Juhl a écrit :
>> > We allocate memory for 'new_data' with kmalloc(). If we get the memory
>> > we then try to build_skb() and if that should fail (which it can) we
>> > do not enter 'if (likely(skb)) {' and actually use 'new_data' but
>> > instead fall through to the 'drop:' label and end up returning from
>> > the function without ever assigning 'new'data' to anything or freeing
>> > it. That leaks the memory allocated to 'new_data'.
>> > 
>> > This patch fixes the memory leak by doing a kfree(new_data) in the
>> > case where build_skb() fails (or where allocation of 'new_data' itself
>> > fails, but in taht case it's just a harmless kfree(NULL)).
>> > 
>> > Signed-off-by: Jesper Juhl <jj@chaosbits.net>
...
>> Good catch, my bad.
>> 
>> Thanks
>> 
>> Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
> 
> Indeed - nice catch. Thanks Jesper.
> 
> Acked-by: Eilon Greenstein <eilong@broadcom.com>

Applied, thanks everyone.

      reply	other threads:[~2012-02-07 18:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-06 21:28 [PATCH] bnx2x: Fix mem leak in bnx2x_tpa_stop() if build_skb() fails Jesper Juhl
2012-02-06 22:53 ` Eric Dumazet
2012-02-07  6:55   ` Eilon Greenstein
2012-02-07 18:14     ` 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=20120207.131413.1550725807432901999.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=eilong@broadcom.com \
    --cc=eliezert@broadcom.com \
    --cc=eric.dumazet@gmail.com \
    --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 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).