From: David Miller <davem@davemloft.net>
To: herbert@gondor.apana.org.au
Cc: jarkao2@gmail.com, jeff@garzik.org, netdev@vger.kernel.org
Subject: Re: [PATCH] pppoe: Add missing sock_put() in pppoe_rcv()
Date: Thu, 30 Oct 2008 23:11:59 -0700 (PDT) [thread overview]
Message-ID: <20081030.231159.155700598.davem@davemloft.net> (raw)
In-Reply-To: <20081031042920.GA6101@gondor.apana.org.au>
From: Herbert Xu <herbert@gondor.apana.org.au>
Date: Fri, 31 Oct 2008 12:29:20 +0800
> On Thu, Oct 30, 2008 at 08:57:25AM +0000, Jarek Poplawski wrote:
> >
> > diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
> > index fc6f4b8..c074276 100644
> > --- a/drivers/net/pppoe.c
> > +++ b/drivers/net/pppoe.c
> > @@ -403,8 +403,10 @@ static int pppoe_rcv(struct sk_buff *skb,
> > if (!po)
> > goto drop;
> >
> > - if (pskb_trim_rcsum(skb, len))
> > + if (pskb_trim_rcsum(skb, len)) {
> > + sock_put(sk_pppox(po));
> > goto drop;
> > + }
>
> Actually we might be better off moving the trim before the get_item
> call.
That sounds like a good idea, I'll commit the following:
commit fb764c5b742fdab5615f4a1bac9f43df73599ce3
Author: David S. Miller <davem@davemloft.net>
Date: Thu Oct 30 23:11:44 2008 -0700
pppoe: Fix socket leak.
Move SKB trim before we lookup the socket so we don't have to
put it on failure.
Based upon an initial patch by Jarek Poplawski and suggestions
from Herbert Xu.
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c
index fc6f4b8..b646e92 100644
--- a/drivers/net/pppoe.c
+++ b/drivers/net/pppoe.c
@@ -399,11 +399,11 @@ static int pppoe_rcv(struct sk_buff *skb,
if (skb->len < len)
goto drop;
- po = get_item(ph->sid, eth_hdr(skb)->h_source, dev->ifindex);
- if (!po)
+ if (pskb_trim_rcsum(skb, len))
goto drop;
- if (pskb_trim_rcsum(skb, len))
+ po = get_item(ph->sid, eth_hdr(skb)->h_source, dev->ifindex);
+ if (!po)
goto drop;
return sk_receive_skb(sk_pppox(po), skb, 0);
prev parent reply other threads:[~2008-10-31 6:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-30 8:57 [PATCH] pppoe: Add missing sock_put() in pppoe_rcv() Jarek Poplawski
2008-10-31 4:26 ` Herbert Xu
2008-10-31 4:29 ` Herbert Xu
2008-10-31 6:11 ` 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=20081030.231159.155700598.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=jarkao2@gmail.com \
--cc=jeff@garzik.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