Commit 44f3dd08 authored by Olivier Fourdan's avatar Olivier Fourdan
Browse files

linux: Set number of devices to 0 in case of error

pci_sys is a global variable which is populated on init, and in case of
error reading sysfs on Linux, the devices are NULL, but the number of
devices is left unchanged.

As a result, we may crash in `pci_device_next()` which relies on the
number of devices.

To fix the issue, simply reset the number of devices to zero in case of
error so we don't try to access indices of a NULL array later on.
Signed-off-by: default avatarOlivier Fourdan <>
parent 13854f60
......@@ -264,6 +264,7 @@ populate_entries( struct pci_system * p )
if (err) {
p->devices = NULL;
p->num_devices = 0;
return err;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment