kni: fix crash when removing interface
authorFerruh Yigit <ferruh.yigit@intel.com>
Wed, 31 Aug 2016 13:06:26 +0000 (14:06 +0100)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Fri, 9 Sep 2016 13:47:48 +0000 (15:47 +0200)
Removing KNI interface that has no PCI driver for ethtool support cause
kernel crash.

Fixes: 109febfe58f9 ("net/igb: move PCI device IDs from EAL")
Fixes: 221fba3b987c ("net/ixgbe: move PCI device IDs from EAL")

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
lib/librte_eal/linuxapp/kni/kni_misc.c

index 67e9b7d..4f07507 100644 (file)
@@ -355,10 +355,12 @@ kni_dev_remove(struct kni_dev *dev)
        if (!dev)
                return -ENODEV;
 
-       if (pci_match_id(ixgbe_pci_tbl, dev->pci_dev))
-               ixgbe_kni_remove(dev->pci_dev);
-       else if (pci_match_id(igb_pci_tbl, dev->pci_dev))
-               igb_kni_remove(dev->pci_dev);
+       if (dev->pci_dev) {
+               if (pci_match_id(ixgbe_pci_tbl, dev->pci_dev))
+                       ixgbe_kni_remove(dev->pci_dev);
+               else if (pci_match_id(igb_pci_tbl, dev->pci_dev))
+                       igb_kni_remove(dev->pci_dev);
+       }
 
        if (dev->net_dev) {
                unregister_netdev(dev->net_dev);