[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAPgLHd9KNN81cPYv3bGzoBwUtnJSAoX4NN0Fh+wNgoHE_t7d=w@mail.gmail.com>
Date: Mon, 26 Dec 2011 17:02:59 +0800
From: Wei Yongjun <weiyj.lk@...il.com>
To: davem@...emloft.net
Cc: netdev@...r.kernel.org
Subject: [PATCH] packet: fix dev refcnt leak when bind fail
From: Wei Yongjun <yongjun_wei@...ndmicro.com.cn>
If bind is fail such as bind is called after set PACKET_FANOUT
sock option, the dev refcnt will leak.
Signed-off-by: Wei Yongjun <yongjun_wei@...ndmicro.com.cn>
---
net/packet/af_packet.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 3891702..b6ac234 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2501,8 +2501,11 @@ static int packet_bind_spkt(struct socket *sock, struct sockaddr *uaddr,
strlcpy(name, uaddr->sa_data, sizeof(name));
dev = dev_get_by_name(sock_net(sk), name);
- if (dev)
+ if (dev) {
err = packet_do_bind(sk, dev, pkt_sk(sk)->num);
+ if (err)
+ dev_put(dev);
+ }
return err;
}
@@ -2530,6 +2533,8 @@ static int packet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len
goto out;
}
err = packet_do_bind(sk, dev, sll->sll_protocol ? : pkt_sk(sk)->num);
+ if (err && dev)
+ dev_put(dev);
out:
return err;
--
1.7.7
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists