Patchwork [net-next] netpoll: fix a missing dev refcounting

login
register
mail settings
Submitter Amerigo Wang
Date Jan. 17, 2013, 4:21 a.m.
Message ID <1358396468-14938-1-git-send-email-amwang@redhat.com>
Download mbox | patch
Permalink /patch/213140/
State Accepted
Delegated to: David Miller
Headers show

Comments

Amerigo Wang - Jan. 17, 2013, 4:21 a.m.
__dev_get_by_name() doesn't refcount the network device,
so we have to do this by ourselves. Noticed by Eric.

Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>

---
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Jan. 17, 2013, 4:33 a.m.
From: Cong Wang <amwang@redhat.com>
Date: Thu, 17 Jan 2013 12:21:08 +0800

> __dev_get_by_name() doesn't refcount the network device,
> so we have to do this by ourselves. Noticed by Eric.
> 
> Cc: Eric Dumazet <eric.dumazet@gmail.com>
> Cc: Jiri Pirko <jiri@resnulli.us>
> Cc: David S. Miller <davem@davemloft.net>
> Signed-off-by: Cong Wang <amwang@redhat.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index a5ad1c1..a9b1004 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -1056,6 +1056,7 @@  int netpoll_setup(struct netpoll *np)
 		err = -ENODEV;
 		goto unlock;
 	}
+	dev_hold(ndev);
 
 	if (netdev_master_upper_dev_get(ndev)) {
 		np_err(np, "%s is a slave device, aborting\n", np->dev_name);