]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
hv_netvsc: dev hold/put reference to VF
authorStephen Hemminger <sthemmin@microsoft.com>
Thu, 22 Sep 2016 23:56:30 +0000 (16:56 -0700)
committerLuis Henriques <luis.henriques@canonical.com>
Fri, 20 Jan 2017 13:04:58 +0000 (13:04 +0000)
BugLink: http://bugs.launchpad.net/bugs/1650059
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 <sthemmin@microsoft.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 07d0f0008c783d2a2fce8497000938db15fd7aa1)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Acked-by: Brad Figg <brad.figg@canonical.com>
Acked-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
drivers/net/hyperv/netvsc_drv.c

index d13373ed6af106355aa40443fcce8f776d1d6768..95389c2249f7f0def7451b754dd7d3767d47c5e5 100644 (file)
@@ -1269,6 +1269,8 @@ static int netvsc_register_vf(struct net_device *vf_netdev)
         * Take a reference on the module.
         */
        try_module_get(THIS_MODULE);
+
+       dev_hold(vf_netdev);
        net_device_ctx->vf_netdev = vf_netdev;
        return NOTIFY_OK;
 }
@@ -1383,6 +1385,7 @@ static int netvsc_unregister_vf(struct net_device *vf_netdev)
        netdev_info(ndev, "VF unregistering: %s\n", vf_netdev->name);
        netvsc_inject_disable(net_device_ctx);
        net_device_ctx->vf_netdev = NULL;
+       dev_put(vf_netdev);
        module_put(THIS_MODULE);
        return NOTIFY_OK;
 }