From patchwork Mon Feb 11 20:25:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neil Horman X-Patchwork-Id: 219680 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 577D92C02EA for ; Tue, 12 Feb 2013 07:26:31 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932153Ab3BKU00 (ORCPT ); Mon, 11 Feb 2013 15:26:26 -0500 Received: from charlotte.tuxdriver.com ([70.61.120.58]:35212 "EHLO smtp.tuxdriver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932095Ab3BKU0Y (ORCPT ); Mon, 11 Feb 2013 15:26:24 -0500 Received: from hmsreliant.think-freely.org ([2001:470:8:a08:7aac:c0ff:fec2:933b] helo=localhost) by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1U4zxE-0003hT-0P; Mon, 11 Feb 2013 15:26:22 -0500 From: Neil Horman To: netdev@vger.kernel.org Cc: Neil Horman , fengguang.wu@intel.com, David Miller , eric.dumazet@gmail.com Subject: [PATCH v2 2/2] netpoll: cleanup sparse warnings Date: Mon, 11 Feb 2013 15:25:31 -0500 Message-Id: <1360614331-29247-3-git-send-email-nhorman@tuxdriver.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1360614331-29247-1-git-send-email-nhorman@tuxdriver.com> References: <1360248961-30721-1-git-send-email-nhorman@tuxdriver.com> <1360614331-29247-1-git-send-email-nhorman@tuxdriver.com> X-Spam-Score: -2.9 (--) X-Spam-Status: No Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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. I've validated these changes using CONFIG_PROVE_RCU while starting and stopping netconsole repeatedly in bonded and non-bonded configurations Signed-offy-by: Neil Horman CC: fengguang.wu@intel.com CC: David Miller CC: eric.dumazet@gmail.com --- 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 c536474..bcfd4f4 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -206,7 +206,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)) @@ -221,7 +221,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) { @@ -1056,7 +1056,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); } @@ -1236,7 +1236,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 = rtnl_dereference(np->dev->npinfo); if (!npinfo) return;