netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netpoll: cleanup sparse warnings
@ 2013-02-07 14:56 Neil Horman
  2013-02-07 15:52 ` Eric Dumazet
  2013-02-11 20:25 ` [PATCH v2 0/2] netpoll: Cleanup netpoll locking and " Neil Horman
  0 siblings, 2 replies; 14+ messages in thread
From: Neil Horman @ 2013-02-07 14:56 UTC (permalink / raw)
  To: netdev; +Cc: Neil Horman, fengguang.wu, David Miller

With my recent commit I introduced two sparse warnings.  Looking closer there
were a few more in the same file, so I fixed them all up.  Basic rcu pointer
dereferencing suff

Signed-offy-by: Neil Horman <nhorman@tuxdriver.com>
CC: fengguang.wu@intel.com
CC: David Miller <davem@davemloft.net>
---
 net/core/netpoll.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index edcd9ad..1c829c0 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -205,7 +205,7 @@ static void netpoll_poll_dev(struct net_device *dev)
 	 * the dev_open/close paths use this to block netpoll activity
 	 * while changing device state
 	 */
-	if (!mutex_trylock(&dev->npinfo->dev_lock))
+	if (!mutex_trylock(&ni->dev_lock))
 		return;
 
 	if (!dev || !netif_running(dev))
@@ -220,7 +220,7 @@ static void netpoll_poll_dev(struct net_device *dev)
 
 	poll_napi(dev);
 
-	mutex_unlock(&dev->npinfo->dev_lock);
+	mutex_unlock(&ni->dev_lock);
 
 	if (dev->flags & IFF_SLAVE) {
 		if (ni) {
@@ -1054,7 +1054,7 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev, gfp_t gfp)
 				goto free_npinfo;
 		}
 	} else {
-		npinfo = ndev->npinfo;
+		npinfo = rtnl_dereference(ndev->npinfo);
 		atomic_inc(&npinfo->refcnt);
 	}
 
@@ -1234,7 +1234,11 @@ void __netpoll_cleanup(struct netpoll *np)
 	struct netpoll_info *npinfo;
 	unsigned long flags;
 
-	npinfo = np->dev->npinfo;
+	/* rtnl_dereference would be preferable here but
+	 * rcu_cleanup_netpoll path can put us in here safely without
+	 * holding the rtnl, so plain rcu_dereference it is
+	 */
+	npinfo = rcu_dereference(np->dev->npinfo);
 	if (!npinfo)
 		return;
 
-- 
1.7.11.7

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2013-02-12  0:19 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-07 14:56 [PATCH] netpoll: cleanup sparse warnings Neil Horman
2013-02-07 15:52 ` Eric Dumazet
2013-02-07 18:37   ` Neil Horman
2013-02-08  3:25     ` Eric Dumazet
2013-02-08 15:47       ` Neil Horman
2013-02-08 16:44         ` Eric Dumazet
2013-02-08 18:14           ` Neil Horman
2013-02-11 20:25 ` [PATCH v2 0/2] netpoll: Cleanup netpoll locking and " Neil Horman
2013-02-11 20:25   ` [PATCH v2 1/2] netpoll: Fix __netpoll_rcu_free so that it can hold the rtnl lock Neil Horman
2013-02-12  0:19     ` David Miller
2013-02-11 20:25   ` [PATCH v2 2/2] netpoll: cleanup sparse warnings Neil Horman
2013-02-12  0:19     ` David Miller
2013-02-11 21:11   ` [PATCH v2 0/2] netpoll: Cleanup netpoll locking and " David Miller
2013-02-11 21:51     ` Neil Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).