Commit 07d0f000 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by David S. Miller

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: default avatarStephen Hemminger <sthemmin@microsoft.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 17db4bce
...@@ -1262,6 +1262,8 @@ static int netvsc_register_vf(struct net_device *vf_netdev) ...@@ -1262,6 +1262,8 @@ static int netvsc_register_vf(struct net_device *vf_netdev)
* Take a reference on the module. * Take a reference on the module.
*/ */
try_module_get(THIS_MODULE); try_module_get(THIS_MODULE);
dev_hold(vf_netdev);
net_device_ctx->vf_netdev = vf_netdev; net_device_ctx->vf_netdev = vf_netdev;
return NOTIFY_OK; return NOTIFY_OK;
} }
...@@ -1376,6 +1378,7 @@ static int netvsc_unregister_vf(struct net_device *vf_netdev) ...@@ -1376,6 +1378,7 @@ static int netvsc_unregister_vf(struct net_device *vf_netdev)
netdev_info(ndev, "VF unregistering: %s\n", vf_netdev->name); netdev_info(ndev, "VF unregistering: %s\n", vf_netdev->name);
netvsc_inject_disable(net_device_ctx); netvsc_inject_disable(net_device_ctx);
net_device_ctx->vf_netdev = NULL; net_device_ctx->vf_netdev = NULL;
dev_put(vf_netdev);
module_put(THIS_MODULE); module_put(THIS_MODULE);
return NOTIFY_OK; return NOTIFY_OK;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment