xfree86: Fix potentially NULL reference to platform device's PCI device

xf86_platform_devices[i].pdev may be NULL in cases we fail to parse the
busid in config_udev_odev_setup_attribs() (see also [1], [2]) such as
when udev does not give use ID_PATH. This in turn leads to
platform_find_pci_info() being not called and pdev being NULL.

[1]: https://gitlab.freedesktop.org/xorg/xserver/-/issues/993
[2]: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1076

Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
This commit is contained in:
Povilas Kanapickas 2021-03-26 00:51:02 +02:00
parent 303763941f
commit 0d93bbfa2c
2 changed files with 9 additions and 4 deletions

View File

@ -365,10 +365,12 @@ xf86MergeOutputClassOptions(int entityIndex, void **options)
break;
case BUS_PCI:
for (i = 0; i < xf86_num_platform_devices; i++) {
if (MATCH_PCI_DEVICES(xf86_platform_devices[i].pdev,
entity->bus.id.pci)) {
dev = &xf86_platform_devices[i];
break;
if (xf86_platform_devices[i].pdev) {
if (MATCH_PCI_DEVICES(xf86_platform_devices[i].pdev,
entity->bus.id.pci)) {
dev = &xf86_platform_devices[i];
break;
}
}
}
break;

View File

@ -85,6 +85,9 @@ xf86PlatformDeviceCheckBusID(struct xf86_platform_device *device, const char *bu
bustype = StringToBusType(busid, &id);
if (bustype == BUS_PCI) {
struct pci_device *pPci = device->pdev;
if (!pPci)
return FALSE;
if (xf86ComparePciBusString(busid,
((pPci->domain << 8)
| pPci->bus),