Skip to content
  • Olivier Fourdan's avatar
    linux: Set number of devices to 0 in case of error · 44f3dd08
    Olivier Fourdan authored
    
    
    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 <ofourdan@redhat.com>
    44f3dd08