aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Fedin <p.fedin@samsung.com>2015-11-16 09:51:34 -0500
committerDavid S. Miller <davem@davemloft.net>2015-11-16 16:24:44 -0500
commit7750130d93decff06120df0d8ea024ff8a038a21 (patch)
treeacb06327cdf15112241f13b7a45f9a98e0411ef7
parent88ad4175b201ae24be5e9b7752cf33c1306b64e4 (diff)
net: thunder: Check for driver data in nicvf_remove()
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>
-rw-r--r--drivers/net/ethernet/cavium/thunder/nicvf_main.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index 372c39e5bcbd..7f709cbdcd87 100644
--- a/drivers/net/ethernet/cavium/thunder/nicvf_main.c
+++ b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
@@ -1583,8 +1583,14 @@ err_disable_device:
1583static void nicvf_remove(struct pci_dev *pdev) 1583static void nicvf_remove(struct pci_dev *pdev)
1584{ 1584{
1585 struct net_device *netdev = pci_get_drvdata(pdev); 1585 struct net_device *netdev = pci_get_drvdata(pdev);
1586 struct nicvf *nic = netdev_priv(netdev); 1586 struct nicvf *nic;
1587 struct net_device *pnetdev = nic->pnicvf->netdev; 1587 struct net_device *pnetdev;
1588
1589 if (!netdev)
1590 return;
1591
1592 nic = netdev_priv(netdev);
1593 pnetdev = nic->pnicvf->netdev;
1588 1594
1589 /* Check if this Qset is assigned to different VF. 1595 /* Check if this Qset is assigned to different VF.
1590 * If yes, clean primary and all secondary Qsets. 1596 * If yes, clean primary and all secondary Qsets.
@@ -1600,9 +1606,6 @@ static void nicvf_remove(struct pci_dev *pdev)
1600 1606
1601static void nicvf_shutdown(struct pci_dev *pdev) 1607static void nicvf_shutdown(struct pci_dev *pdev)
1602{ 1608{
1603 if (!pci_get_drvdata(pdev))
1604 return;
1605
1606 nicvf_remove(pdev); 1609 nicvf_remove(pdev);
1607} 1610}
1608 1611