提交 7750130d 编写于 作者: P Pavel Fedin 提交者: David S. Miller

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: NPavel Fedin <p.fedin@samsung.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 88ad4175
...@@ -1583,8 +1583,14 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -1583,8 +1583,14 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
static void nicvf_remove(struct pci_dev *pdev) static void nicvf_remove(struct pci_dev *pdev)
{ {
struct net_device *netdev = pci_get_drvdata(pdev); struct net_device *netdev = pci_get_drvdata(pdev);
struct nicvf *nic = netdev_priv(netdev); struct nicvf *nic;
struct net_device *pnetdev = nic->pnicvf->netdev; struct net_device *pnetdev;
if (!netdev)
return;
nic = netdev_priv(netdev);
pnetdev = nic->pnicvf->netdev;
/* Check if this Qset is assigned to different VF. /* Check if this Qset is assigned to different VF.
* If yes, clean primary and all secondary Qsets. * If yes, clean primary and all secondary Qsets.
...@@ -1600,9 +1606,6 @@ static void nicvf_remove(struct pci_dev *pdev) ...@@ -1600,9 +1606,6 @@ static void nicvf_remove(struct pci_dev *pdev)
static void nicvf_shutdown(struct pci_dev *pdev) static void nicvf_shutdown(struct pci_dev *pdev)
{ {
if (!pci_get_drvdata(pdev))
return;
nicvf_remove(pdev); nicvf_remove(pdev);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册