浏览代码

ntb_netdev: Fix list_for_each_entry exit issue

If list_for_each_entry exits without finding the ntb_device, the dev
pointer will not be NULL.  Thus the check will never be true and the
code will not exit when it should.  Correct this by adding a bool to
determine when the device is found, otherwise exit in good fashion.

Signed-off-by: Jon Mason <jon.mason@intel.com>
Jon Mason 11 年之前
父节点
当前提交
fea903ecd7
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      drivers/net/ntb_netdev.c

+ 5 - 2
drivers/net/ntb_netdev.c

@@ -367,12 +367,15 @@ static void ntb_netdev_remove(struct pci_dev *pdev)
 {
 {
 	struct net_device *ndev;
 	struct net_device *ndev;
 	struct ntb_netdev *dev;
 	struct ntb_netdev *dev;
+	bool found  = false;
 
 
 	list_for_each_entry(dev, &dev_list, list) {
 	list_for_each_entry(dev, &dev_list, list) {
-		if (dev->pdev == pdev)
+		if (dev->pdev == pdev) {
+			found = true;
 			break;
 			break;
+		}
 	}
 	}
-	if (dev == NULL)
+	if (!found)
 		return;
 		return;
 
 
 	list_del(&dev->list);
 	list_del(&dev->list);