Skip to content

Commit

Permalink
net: thunder: Check for driver data in nicvf_remove()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Pavel Fedin authored and David S. Miller committed Nov 16, 2015
1 parent 88ad417 commit 7750130
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions drivers/net/ethernet/cavium/thunder/nicvf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
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.
Expand All @@ -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);
}

Expand Down

0 comments on commit 7750130

Please sign in to comment.