* [PATCH net v2] hv_netvsc: Fix a warning of suspicious RCU usage
@ 2019-08-09 1:58 Dexuan Cui
2019-08-09 20:42 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Dexuan Cui @ 2019-08-09 1:58 UTC (permalink / raw)
To: netdev, David S. Miller, Haiyang Zhang, Stephen Hemminger,
Jakub Kicinski
Cc: sashal, KY Srinivasan, Michael Kelley, linux-hyperv,
linux-kernel, olaf, apw, jasowang, vkuznets, marcelo.cerri
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 <decui@microsoft.com>
---
Changes in v2:
Made the minimal required change.
Added a Fixes tag.
Removed Stephen H.'s Signed-off-by since this is somewhat different from the
v1 from him; if there is any bug in v2, it's all my fault. :-)
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 f9209594624b..b6357a75712c 100644
--- a/drivers/net/hyperv/netvsc_drv.c
+++ b/drivers/net/hyperv/netvsc_drv.c
@@ -1240,12 +1240,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);
@@ -1284,6 +1287,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.19.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net v2] hv_netvsc: Fix a warning of suspicious RCU usage
2019-08-09 1:58 [PATCH net v2] hv_netvsc: Fix a warning of suspicious RCU usage Dexuan Cui
@ 2019-08-09 20:42 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-08-09 20:42 UTC (permalink / raw)
To: decui
Cc: netdev, haiyangz, sthemmin, jakub.kicinski, sashal, kys,
mikelley, linux-hyperv, linux-kernel, olaf, apw, jasowang,
vkuznets, marcelo.cerri
From: Dexuan Cui <decui@microsoft.com>
Date: Fri, 9 Aug 2019 01:58:08 +0000
> 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 <decui@microsoft.com>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-08-09 20:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-09 1:58 [PATCH net v2] hv_netvsc: Fix a warning of suspicious RCU usage Dexuan Cui
2019-08-09 20:42 ` David Miller
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).