netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] packet: fix possible dev refcnt leak when bind fail
@ 2011-12-28  2:53 Wei Yongjun
  2011-12-28  3:33 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2011-12-28  2:53 UTC (permalink / raw)
  To: davem; +Cc: netdev

From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

If bind is fail when bind is called after set PACKET_FANOUT
sock option, the dev refcnt will leak.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 net/packet/af_packet.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 3891702..d9d4970 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2448,8 +2448,12 @@ static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protoc
 {
 	struct packet_sock *po = pkt_sk(sk);
 
-	if (po->fanout)
+	if (po->fanout) {
+		if (dev)
+			dev_put(dev);
+
 		return -EINVAL;
+	}
 
 	lock_sock(sk);
 
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] packet: fix possible dev refcnt leak when bind fail
  2011-12-28  2:53 [PATCH v2] packet: fix possible dev refcnt leak when bind fail Wei Yongjun
@ 2011-12-28  3:33 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-12-28  3:33 UTC (permalink / raw)
  To: weiyj.lk; +Cc: netdev

From: Wei Yongjun <weiyj.lk@gmail.com>
Date: Wed, 28 Dec 2011 10:53:05 +0800

> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> If bind is fail when bind is called after set PACKET_FANOUT
> sock option, the dev refcnt will leak.
> 
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Applied, thanks a lot.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-12-28  3:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-28  2:53 [PATCH v2] packet: fix possible dev refcnt leak when bind fail Wei Yongjun
2011-12-28  3:33 ` David Miller

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).