]> xenbits.xensource.com Git - people/royger/freebsd.git/commitdiff
linuxkpi: Fix not-found case of linux_pci_find_irq_dev
authorcem <cem@FreeBSD.org>
Tue, 13 Dec 2016 19:58:21 +0000 (19:58 +0000)
committercem <cem@FreeBSD.org>
Tue, 13 Dec 2016 19:58:21 +0000 (19:58 +0000)
Linux list_for_each_entry() does not neccessarily end with the iterator
NULL (it may be an offset from NULL if the list member is not the first
element of the member struct).

Reported by: Coverity
CID: 1366940
Reviewed by: hselasky@
Sponsored by: Dell EMC Isilon
Differential Revision: https://reviews.freebsd.org/D8780

sys/compat/linuxkpi/common/include/linux/pci.h

index 305fa6f312aec0e84e8c6730662790e4ed67591c..a7fcb04c480fda30c9b6224894352c4b8c6e7053 100644 (file)
@@ -220,18 +220,19 @@ static inline struct device *
 linux_pci_find_irq_dev(unsigned int irq)
 {
        struct pci_dev *pdev;
+       struct device *found;
 
+       found = NULL;
        spin_lock(&pci_lock);
        list_for_each_entry(pdev, &pci_devices, links) {
-               if (irq == pdev->dev.irq)
-                       break;
-               if (irq >= pdev->dev.msix && irq < pdev->dev.msix_max)
+               if (irq == pdev->dev.irq ||
+                   (irq >= pdev->dev.msix && irq < pdev->dev.msix_max)) {
+                       found = &pdev->dev;
                        break;
+               }
        }
        spin_unlock(&pci_lock);
-       if (pdev)
-               return &pdev->dev;
-       return (NULL);
+       return (found);
 }
 
 static inline unsigned long