Skip to content

Commit 79e8cbe

Browse files
shemmingerdavem330
authored andcommitted
netvsc: add some rtnl_dereference annotations
In a couple places RTNL is held, and the netvsc_device pointer is acquired without annotation. Signed-off-by: Stephen Hemminger <sthemmin@microsoft.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1b01994 commit 79e8cbe

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

drivers/net/hyperv/netvsc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void netvsc_switch_datapath(struct net_device *ndev, bool vf)
4141
{
4242
struct net_device_context *net_device_ctx = netdev_priv(ndev);
4343
struct hv_device *dev = net_device_ctx->device_ctx;
44-
struct netvsc_device *nv_dev = net_device_ctx->nvdev;
44+
struct netvsc_device *nv_dev = rtnl_dereference(net_device_ctx->nvdev);
4545
struct nvsp_message *init_pkt = &nv_dev->channel_init_pkt;
4646

4747
memset(init_pkt, 0, sizeof(struct nvsp_message));
@@ -549,7 +549,8 @@ void netvsc_device_remove(struct hv_device *device)
549549
{
550550
struct net_device *ndev = hv_get_drvdata(device);
551551
struct net_device_context *net_device_ctx = netdev_priv(ndev);
552-
struct netvsc_device *net_device = net_device_ctx->nvdev;
552+
struct netvsc_device *net_device
553+
= rtnl_dereference(net_device_ctx->nvdev);
553554
int i;
554555

555556
netvsc_disconnect_vsp(device);

drivers/net/hyperv/netvsc_drv.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static void netvsc_set_multicast_list(struct net_device *net)
6969
static int netvsc_open(struct net_device *net)
7070
{
7171
struct net_device_context *ndev_ctx = netdev_priv(net);
72-
struct netvsc_device *nvdev = ndev_ctx->nvdev;
72+
struct netvsc_device *nvdev = rtnl_dereference(ndev_ctx->nvdev);
7373
struct rndis_device *rdev;
7474
int ret = 0;
7575

@@ -1364,7 +1364,7 @@ static struct net_device *get_netvsc_byref(struct net_device *vf_netdev)
13641364
continue; /* not a netvsc device */
13651365

13661366
net_device_ctx = netdev_priv(dev);
1367-
if (net_device_ctx->nvdev == NULL)
1367+
if (!rtnl_dereference(net_device_ctx->nvdev))
13681368
continue; /* device is removed */
13691369

13701370
if (rtnl_dereference(net_device_ctx->vf_netdev) == vf_netdev)
@@ -1589,7 +1589,8 @@ static int netvsc_remove(struct hv_device *dev)
15891589
* removed. Also blocks mtu and channel changes.
15901590
*/
15911591
rtnl_lock();
1592-
rndis_filter_device_remove(dev, ndev_ctx->nvdev);
1592+
rndis_filter_device_remove(dev,
1593+
rtnl_dereference(ndev_ctx->nvdev));
15931594
rtnl_unlock();
15941595

15951596
unregister_netdev(net);

0 commit comments

Comments
 (0)