xserver: Branch 'master' - 2 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Jun 23 11:33:19 UTC 2021


 hw/xfree86/common/xf86Bus.c                |    3 ++-
 hw/xfree86/common/xf86platformBus.c        |   10 ++++++----
 hw/xfree86/os-support/linux/lnx_platform.c |    3 +++
 3 files changed, 11 insertions(+), 5 deletions(-)

New commits:
commit 0d93bbfa2cfacbb73741f8bed0e32fa1a656b928
Author: Povilas Kanapickas <povilas at radix.lt>
Date:   Fri Mar 26 00:51:02 2021 +0200

    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 at gmail.com>
    Signed-off-by: Povilas Kanapickas <povilas at radix.lt>

diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
index ee2f3f86a..e43ff69af 100644
--- a/hw/xfree86/common/xf86platformBus.c
+++ b/hw/xfree86/common/xf86platformBus.c
@@ -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;
diff --git a/hw/xfree86/os-support/linux/lnx_platform.c b/hw/xfree86/os-support/linux/lnx_platform.c
index fe2142182..8a6be97aa 100644
--- a/hw/xfree86/os-support/linux/lnx_platform.c
+++ b/hw/xfree86/os-support/linux/lnx_platform.c
@@ -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),
commit 303763941f9941e2e215a3c978b72de495478033
Author: Povilas Kanapickas <povilas at radix.lt>
Date:   Fri Mar 26 00:51:01 2021 +0200

    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 <povilas at radix.lt>

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)


More information about the xorg-commit mailing list