From 303763941f9941e2e215a3c978b72de495478033 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Fri, 26 Mar 2021 00:51:01 +0200 Subject: [PATCH] xfree86: Consistently check for reference to primaryBus pci_device This is the only place where we don't check whether primaryBus.id.plat->pdev is not NULL before accessing its members. It 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 in one of the items within the xf86_platform_devices array. For this to cause a crash we only need it to become the primaryBus device. [1]: https://gitlab.freedesktop.org/xorg/xserver/-/issues/993 [2]: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1076 Signed-off-by: Povilas Kanapickas --- hw/xfree86/common/xf86Bus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c index 5e34eab99..272ad4cbe 100644 --- a/hw/xfree86/common/xf86Bus.c +++ b/hw/xfree86/common/xf86Bus.c @@ -296,7 +296,8 @@ xf86IsEntityPrimary(int entityIndex) #ifdef XSERVER_LIBPCIACCESS if (primaryBus.type == BUS_PLATFORM && pEnt->bus.type == BUS_PCI) - return MATCH_PCI_DEVICES(pEnt->bus.id.pci, primaryBus.id.plat->pdev); + if (primaryBus.id.plat->pdev) + return MATCH_PCI_DEVICES(pEnt->bus.id.pci, primaryBus.id.plat->pdev); #endif if (primaryBus.type != pEnt->bus.type)