]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC 303881: Reliably return PCI_GETCONF_LAST_DEVICE from PCIOCGETCONF.
authorjhb <jhb@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 30 Sep 2016 01:13:57 +0000 (01:13 +0000)
committerjhb <jhb@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 30 Sep 2016 01:13:57 +0000 (01:13 +0000)
commite8015585267a067662739914effff46c16654496
treeb51a8d4ed9970ae30d90a5df8238aa6441540d35
parente19eb45e795602a9e58d32e353a1b6faa7dfdd05
MFC 303881: Reliably return PCI_GETCONF_LAST_DEVICE from PCIOCGETCONF.

Previously the loop in PCIIOCGETCONF would terminate as soon as it
found enough matches.  Now it will continue iterating through the
PCI device list and only terminate if it finds another matching device
for which it has no room to store a conf structure.  This means that
PCI_GETCONF_LAST_DEVICE is reliably returned when the number of
matching devices is equal to the number of slots in the matches
buffer.  For example, if a program requests the conf structure for a
single PCI function with a specified domain/bus/slot/function it will
now get PCI_GETCONF_LAST_DEVICE instead of PCI_GETCONF_MORE_DEVS.

While here, simplify the loop conditional a bit more by explicitly
breaking out of the loop if copyout() fails and removing a redundant
i < pci_numdevs check.

Sponsored by: Chelsio Communications

git-svn-id: svn://svn.freebsd.org/base/stable/10@306469 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
share/man/man4/pci.4
sys/dev/pci/pci_user.c