From: Wei Yongjun Date: Wed, 28 Dec 2011 03:32:41 +0000 (-0500) Subject: packet: fix possible dev refcnt leak when bind fail X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=aef950b4ba3196622a5bd5e21ab1d63f30658285;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git 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 Signed-off-by: David S. Miller --- diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 3891702b81d..d9d4970b9b0 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);