Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2671099ybl; Thu, 29 Aug 2019 11:15:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQRihlPbXJdq/d/FHbOaL4CxSPUaer4NWG6XgTanwlDv9BSvnGf3eIA3KAshsDzKJ633BF X-Received: by 2002:a65:640d:: with SMTP id a13mr9445388pgv.256.1567102515042; Thu, 29 Aug 2019 11:15:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567102515; cv=none; d=google.com; s=arc-20160816; b=a3lBSIsFpE+Zm0oarL1gtYkuwr0Xj5RZpv09x/0PpTQKJRkEIvOc3NLBsF3wf7RIEc jWcBI9JQTMw01yJYQ720GLxa42+uOBqRdbmGUsn6vDJ3Cqaez12YR7TqOw7OQrzv1nUv RsPu5PjEenGApTxukb5c8iF881c7VgFEavXlHxiRABdYDv7QvmZ5FcGiPhEOLBJ3mWe+ HrkWQivwSrFfd5MLpeZziwEVKKNHVwFAdEj6n8muXAz9eOwMeWPQM2OnMt7dZW5zB3bX fZkJkDX0xpFk5nM5wL8xk120ug4MFLntB3FHCA6iFk+lKw6p3mt3FLUQmDrCy1QWDAqf A0hg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6xGiTnhHq5HJtwNfE9BTbv4o0D+SwR3+5fAFk7z/JrI=; b=iXImrzxWusJyw+s8R+xxA+QUU0xtf8e5lJ38eMUNEmct3TCQ5as9AEHhUj/9oygVbl z5AlogDd4U8XKjYcCZKzNHfnPSqlx9wrhwS6Nwh8Vep94vrQkf3jbtp+UtkRQ+VBDR9h ebkavwNCVSvKgboqmNQR0sOMoJ5a/BpoD8nsJDMfYIN8NnGP48Zl8whs3N5Asn/jrXkA lR7GGv6LXmtRaDXof9MjEfInBbzzqN+QORPYm9vRNM2PFC/wnonbQiBWpTiWESWn9iv6 HOgkw29QQm2zgNtwLfszGACnQkTRdWlZOGukNuKMpYRHGq/bWU9G6g1KEvbihyaLi8wX c5wQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B0ntnSFs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 11si3412190pfj.239.2019.08.29.11.15.00; Thu, 29 Aug 2019 11:15:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B0ntnSFs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728534AbfH2SNs (ORCPT + 99 others); Thu, 29 Aug 2019 14:13:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:55444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728490AbfH2SNp (ORCPT ); Thu, 29 Aug 2019 14:13:45 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5885023405; Thu, 29 Aug 2019 18:13:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567102424; bh=JqJfHtTLl3cwcE+vmBm9Cyl5Qi9vXylINoDckON63Ak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B0ntnSFsnOr14HKpFNEItgGa8N6sK4lpj4kB/vQ8Q/rvP722qc1i2ib4TLywm+kC0 AWAlIE++pF8u4rSUA8LjTFsvVUEDGTxDXt/m8gGIGj8lPzbkEmJpy/pe+1k/oGEC72 q6Rf83NpPhUtTSdn1aVwNjR2K2sFh7a7L4TuNuOQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dexuan Cui , "David S . Miller" , Sasha Levin , linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.2 16/76] hv_netvsc: Fix a warning of suspicious RCU usage Date: Thu, 29 Aug 2019 14:12:11 -0400 Message-Id: <20190829181311.7562-16-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190829181311.7562-1-sashal@kernel.org> References: <20190829181311.7562-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dexuan Cui [ Upstream commit 6d0d779dca73cd5acb649c54f81401f93098b298 ] This fixes a warning of "suspicious rcu_dereference_check() usage" when nload runs. Fixes: 776e726bfb34 ("netvsc: fix RCU warning in get_stats") Signed-off-by: Dexuan Cui Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/hyperv/netvsc_drv.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 3544e19915792..e8fce6d715ef0 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -1239,12 +1239,15 @@ static void netvsc_get_stats64(struct net_device *net, struct rtnl_link_stats64 *t) { struct net_device_context *ndev_ctx = netdev_priv(net); - struct netvsc_device *nvdev = rcu_dereference_rtnl(ndev_ctx->nvdev); + struct netvsc_device *nvdev; struct netvsc_vf_pcpu_stats vf_tot; int i; + rcu_read_lock(); + + nvdev = rcu_dereference(ndev_ctx->nvdev); if (!nvdev) - return; + goto out; netdev_stats_to_stats64(t, &net->stats); @@ -1283,6 +1286,8 @@ static void netvsc_get_stats64(struct net_device *net, t->rx_packets += packets; t->multicast += multicast; } +out: + rcu_read_unlock(); } static int netvsc_set_mac_addr(struct net_device *ndev, void *p) -- 2.20.1