From: Alexander Aring <alex.aring@gmail.com>
To: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH] Bluetooth: 6lowpan: Memory leak as the skb is not freed
Date: Wed, 8 Oct 2014 10:08:47 +0200 [thread overview]
Message-ID: <20141008080846.GC32554@omega> (raw)
In-Reply-To: <20141001072139.GE23043@omega>
Hi Jukka,
On Wed, Oct 01, 2014 at 09:21:39AM +0200, Alexander Aring wrote:
> On Wed, Oct 01, 2014 at 09:08:52AM +0200, Alexander Aring wrote:
> > Hi Jukka,
> >
> > On Wed, Oct 01, 2014 at 10:00:53AM +0300, Jukka Rissanen wrote:
> > > The earlier multicast commit 36b3dd250dde ("Bluetooth: 6lowpan:
> > > Ensure header compression does not corrupt IPv6 header") lost one
> > > skb free which then caused memory leak.
> > >
> > > Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
> > > ---
> > > net/bluetooth/6lowpan.c | 2 ++
> > > 1 file changed, 2 insertions(+)
> > >
> > > diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
> > > index f0432ae..bcbee3d 100644
> > > --- a/net/bluetooth/6lowpan.c
> > > +++ b/net/bluetooth/6lowpan.c
> > > @@ -625,6 +625,8 @@ static netdev_tx_t bt_xmit(struct sk_buff *skb, struct net_device *netdev)
> > > send_mcast_pkt(skb, netdev);
> > > }
> > >
> > > + kfree_skb(skb);
> > > +
> >
> > not dropping afterwards? Then this should be consume_skb or
> > dev_kfree_skb.
> >
> > Also I detected we can't make:
> >
> > skb = skb_unshare(skb, GFP_ATOMIC);
> > if (!skb)
> > return NET_XMIT_DROP;
> >
> > We need something like:
> >
> > tmpskb = skb_unshare(skb, GFP_ATOMIC);
> > if (!tmpskb) {
> > kfree_skb(skb);
> > return NET_XMIT_DROP;
> > }
> > skb = tmpskb;
> >
>
> I mean it depends, I don't see that skb_unshare free the skb when
> allocation failed and then we lost the reference to the skb which
> should be unshared.
>
I look deeper into that now, "skb = skb_unshare(skb, GFP_ATOMIC);"
should work. Sorry for my bad review here.
skb_unshare also free's the skb if allocation failed.
Again, sorry. But now I am sure about the correct behaviour.
- Alex
next prev parent reply other threads:[~2014-10-08 8:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-01 7:00 [PATCH] Bluetooth: 6lowpan: Memory leak as the skb is not freed Jukka Rissanen
2014-10-01 7:08 ` Alexander Aring
2014-10-01 7:21 ` Alexander Aring
2014-10-08 8:08 ` Alexander Aring [this message]
2014-10-01 7:51 ` Jukka Rissanen
-- strict thread matches above, loose matches on Subject: below --
2014-10-01 8:30 Jukka Rissanen
2014-10-02 10:48 ` Johan Hedberg
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=20141008080846.GC32554@omega \
--to=alex.aring@gmail.com \
--cc=jukka.rissanen@linux.intel.com \
--cc=linux-bluetooth@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).