Skip to content

Commit 07d0f00

Browse files
shemmingerdavem330
authored andcommitted
hv_netvsc: dev hold/put reference to VF
The netvsc driver holds a pointer to the virtual function network device if managing SR-IOV association. In order to ensure that the VF network device does not disappear, it should be using dev_hold/dev_put to get a reference count. Signed-off-by: Stephen Hemminger <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 17db4bc commit 07d0f00

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/net/hyperv/netvsc_drv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,6 +1262,8 @@ static int netvsc_register_vf(struct net_device *vf_netdev)
12621262
* Take a reference on the module.
12631263
*/
12641264
try_module_get(THIS_MODULE);
1265+
1266+
dev_hold(vf_netdev);
12651267
net_device_ctx->vf_netdev = vf_netdev;
12661268
return NOTIFY_OK;
12671269
}
@@ -1376,6 +1378,7 @@ static int netvsc_unregister_vf(struct net_device *vf_netdev)
13761378
netdev_info(ndev, "VF unregistering: %s\n", vf_netdev->name);
13771379
netvsc_inject_disable(net_device_ctx);
13781380
net_device_ctx->vf_netdev = NULL;
1381+
dev_put(vf_netdev);
13791382
module_put(THIS_MODULE);
13801383
return NOTIFY_OK;
13811384
}

0 commit comments

Comments
 (0)