Commit d5af7d987a494a1b85e176b4c33dc115cb111662
Committed by
Bjorn Helgaas
1 parent
7629d19a4d
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
PCI: Fix reference count leak in pci_dev_present()
Function pci_get_dev_by_id() takes a reference on the pci_dev returned, so pci_dev_present() should release the corresponding reference. Signed-off-by: Jiang Liu <jiang.liu@huawei.com> Signed-off-by: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Showing 1 changed file with 5 additions and 5 deletions Side-by-side Diff
drivers/pci/search.c
... | ... | @@ -319,13 +319,13 @@ |
319 | 319 | WARN_ON(in_interrupt()); |
320 | 320 | while (ids->vendor || ids->subvendor || ids->class_mask) { |
321 | 321 | found = pci_get_dev_by_id(ids, NULL); |
322 | - if (found) | |
323 | - goto exit; | |
322 | + if (found) { | |
323 | + pci_dev_put(found); | |
324 | + return 1; | |
325 | + } | |
324 | 326 | ids++; |
325 | 327 | } |
326 | -exit: | |
327 | - if (found) | |
328 | - return 1; | |
328 | + | |
329 | 329 | return 0; |
330 | 330 | } |
331 | 331 | EXPORT_SYMBOL(pci_dev_present); |