From fea903ecd799ec49a2ebc4cc8cfb7bb96fd31ddc Mon Sep 17 00:00:00 2001 From: Jon Mason Date: Fri, 22 Nov 2013 16:44:13 -0700 Subject: [PATCH] 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 --- drivers/net/ntb_netdev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ntb_netdev.c b/drivers/net/ntb_netdev.c index f3cdf64997d6..8298880bfdd8 100644 --- a/drivers/net/ntb_netdev.c +++ b/drivers/net/ntb_netdev.c @@ -367,12 +367,15 @@ static void ntb_netdev_remove(struct pci_dev *pdev) { struct net_device *ndev; struct ntb_netdev *dev; + bool found = false; list_for_each_entry(dev, &dev_list, list) { - if (dev->pdev == pdev) + if (dev->pdev == pdev) { + found = true; break; + } } - if (dev == NULL) + if (!found) return; list_del(&dev->list); -- 2.39.5