ixgbe: pci_set_drvdata must be called before register_netdev
authorJeff Mahoney <jeffm@suse.com>
Sat, 3 Jun 2017 22:01:17 +0000 (18:01 -0400)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Wed, 14 Jun 2017 00:36:39 +0000 (17:36 -0700)
We call pci_set_drvdata immediately after calling register_netdev,
which leaves a window where tasks writing to the sriov_numvfs sysfs
attribute can sneak in and crash the kernel.  register_netdev cleans
up after itself so placing pci_set_drvdata immediately before it
should preserve the intent of commit 0fb6a55cc31f ("ixgbe: fix crash
on rmmod after probe fail").

Fixes: 0fb6a55cc31f ("ixgbe: fix crash on rmmod after probe fail")
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

index c17c8317e001699db254923ef9d541b66074897b..f3dc5dea930052df4e928fdc25b23e7ff358f6be 100644 (file)
@@ -10372,11 +10372,11 @@ skip_sriov:
                           "hardware.\n");
        }
        strcpy(netdev->name, "eth%d");
+       pci_set_drvdata(pdev, adapter);
        err = register_netdev(netdev);
        if (err)
                goto err_register;
 
-       pci_set_drvdata(pdev, adapter);
 
        /* power down the optics for 82599 SFP+ fiber */
        if (hw->mac.ops.disable_tx_laser)