Skip to content

Commit

Permalink
packet: fix possible dev refcnt leak when bind fail
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Wei Yongjun authored and David S. Miller committed Dec 28, 2011
1 parent c43c5f3 commit aef950b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit aef950b

Please sign in to comment.