Skip to content

Commit aef950b

Browse files
Wei Yongjundavem330
authored andcommitted
packet: fix possible dev refcnt leak when bind fail
If bind is fail when bind is called after set PACKET_FANOUT sock option, the dev refcnt will leak. Signed-off-by: Wei Yongjun <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c43c5f3 commit aef950b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

net/packet/af_packet.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2448,8 +2448,12 @@ static int packet_do_bind(struct sock *sk, struct net_device *dev, __be16 protoc
24482448
{
24492449
struct packet_sock *po = pkt_sk(sk);
24502450

2451-
if (po->fanout)
2451+
if (po->fanout) {
2452+
if (dev)
2453+
dev_put(dev);
2454+
24522455
return -EINVAL;
2456+
}
24532457

24542458
lock_sock(sk);
24552459

0 commit comments

Comments
 (0)