From: Pavel Fedin
Date: Mon, 16 Nov 2015 14:51:34 +0000 (+0300)
Subject: net: thunder: Check for driver data in nicvf_remove()
X-Git-Tag: v4.3.3~49
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce2ceca37c846767abceee497f8adbb3328a8dd9;p=thirdparty%2Fkernel%2Fstable.git
net: thunder: Check for driver data in nicvf_remove()
[ Upstream commit 7750130d93decff06120df0d8ea024ff8a038a21 ]
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
Signed-off-by: David S. Miller
Signed-off-by: Greg Kroah-Hartman
---
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_main.c b/drivers/net/ethernet/cavium/thunder/nicvf_main.c
index a9377727c11c3..7f709cbdcd87d 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:
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.