Date: Mon, 27 Jul 2026 00:10:31 +0000 From: Bjoern A. Zeeb <bz@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 38734f88a643 - stable/15 - LinuxKPI: fix lkpi_pci_get_device() reference counting on device Message-ID: <6a66a1f7.274f5.76e1f399@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/15 has been updated by bz: URL: https://cgit.FreeBSD.org/src/commit/?id=38734f88a643b139f4d7ecbb53a590db9d678e58 commit 38734f88a643b139f4d7ecbb53a590db9d678e58 Author: Bjoern A. Zeeb <bz@FreeBSD.org> AuthorDate: 2026-06-01 04:58:00 +0000 Commit: Bjoern A. Zeeb <bz@FreeBSD.org> CommitDate: 2026-07-26 16:47:43 +0000 LinuxKPI: fix lkpi_pci_get_device() reference counting on device In case we are passed an "odev" (a device to start the search from), that device would have an extra reference. The best way to illustrate this is to look at for_each_pci_dev(), which will return one device after the other. Upon first return we return a pdev with a reference. That pdev is then passed in as odev on the next call. If we do not clear the reference it will be leaked. Sponsored by: The FreeBSD Foundation Fixes: 910cf345d0ee9 ("LinuxKPI: pci: implement ...") Reviewed by: dumbbell, emaste Differential Revision: https://reviews.freebsd.org/D57428 (cherry picked from commit f9a37065b6948831f62a33fd0c68c96985b01a41) --- sys/compat/linuxkpi/common/src/linux_pci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c index c4f0564c7e35..34ce260bc89d 100644 --- a/sys/compat/linuxkpi/common/src/linux_pci.c +++ b/sys/compat/linuxkpi/common/src/linux_pci.c @@ -308,8 +308,9 @@ linux_pci_find(device_t dev, const struct pci_device_id **idp) struct pci_dev * lkpi_pci_get_device(uint32_t vendor, uint32_t device, struct pci_dev *odev) { - struct pci_dev *pdev, *found; + struct pci_dev *pdev, *found, *odev0; + odev0 = odev; found = NULL; spin_lock(&pci_lock); list_for_each_entry(pdev, &pci_devices, links) { @@ -328,6 +329,7 @@ lkpi_pci_get_device(uint32_t vendor, uint32_t device, struct pci_dev *odev) } pci_dev_get(found); spin_unlock(&pci_lock); + pci_dev_put(odev0); return (found); }home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a66a1f7.274f5.76e1f399>
