]> git.karo-electronics.de Git - linux-beck.git/commitdiff
net: thunder: Check for driver data in nicvf_remove()
authorPavel Fedin <p.fedin@samsung.com>
Mon, 16 Nov 2015 14:51:34 +0000 (17:51 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 16 Nov 2015 21:24:44 +0000 (16:24 -0500)
In some cases the crash is caused by nicvf_remove() being called from
outside. For example, if we try to feed the device to vfio after the
probe has failed for some reason. So, move the check to better place.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/cavium/thunder/nicvf_main.c

index 372c39e5bcbd88860bcd09c7d16471d91e654119..7f709cbdcd87d2f0a0beedd338437218ee0af094 100644 (file)
@@ -1583,8 +1583,14 @@ err_disable_device:
 static void nicvf_remove(struct pci_dev *pdev)
 {
        struct net_device *netdev = pci_get_drvdata(pdev);
-       struct nicvf *nic = netdev_priv(netdev);
-       struct net_device *pnetdev = nic->pnicvf->netdev;
+       struct nicvf *nic;
+       struct net_device *pnetdev;
+
+       if (!netdev)
+               return;
+
+       nic = netdev_priv(netdev);
+       pnetdev = nic->pnicvf->netdev;
 
        /* Check if this Qset is assigned to different VF.
         * If yes, clean primary and all secondary Qsets.
@@ -1600,9 +1606,6 @@ static void nicvf_remove(struct pci_dev *pdev)
 
 static void nicvf_shutdown(struct pci_dev *pdev)
 {
-       if (!pci_get_drvdata(pdev))
-               return;
-
        nicvf_remove(pdev);
 }