yangsong8-a1 opened a new pull request, #22103:
URL: https://github.com/apache/nuttx/pull/22103
## Summary
Devices are linked into bus->devices through their bus_list member
(pci.c: list_add_tail(&dev->bus->devices, &dev->bus_list)), but
pci_do_find_device_from_bus() walked the list with the node member, so
every entry was converted to a wrong device pointer. Any lookup
through pci_find_device_from_bus(), for example the PCIOCGETROMLEN and
PCIOCGETROM ioctls of /dev/pci, read garbage or faulted. Use
bus_list.
The first commit only fixes the nxstyle errors that pci.c already had
on master. It does not change code.
## Impact
drivers/pci/pci.c only. No API change.
## Testing
Ubuntu 22.04, aarch64-none-elf-gcc 13.2.Rel1, qemu-armv8a:nsh with
CONFIG_PCI=y, QEMU 6.2 with two e1000 devices at slots 2 and 3. A test
program issues PCIOCGETROMLEN on /dev/pci for bus 0, devices 1 to 3:
master (data abort in pci_do_find_device_from_bus(), pci.c:163,
`dev->bus->number`):
open /dev/pci: 3
default_fatal_handler: (IFSC/DFSC) for Data/Instruction aborts: level 0
translation fault
arm64_exception_handler: ELR_ELn: 0x402a0578
dump_assert_info: Assertion failed panic: at file:
/arch/arm64/src/common/arm64_fatal.c:696 task: hello process: hello 0x402ba4b4
This PR (no device at slot 1, the two e1000 are found):
open /dev/pci: 3
bus 0 dev 1: PCIOCGETROMLEN ret -1 errno 19 romlen 0
bus 0 dev 2: PCIOCGETROMLEN ret 0 errno 0 romlen 0
bus 0 dev 3: PCIOCGETROMLEN ret 0 errno 0 romlen 0
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]