Hello X.org Team,

while struggling with an older PC with Intel 945GM chip I encountered strange 
segfaults.
After some research I found this entry in the Debian bug tracker:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1140338

The attached patch fixes this issue.


Best regards,
Christoph Baumann

-- 
* Christoph G. Baumann 
* [email protected] 
* http://www.sgoc.de/welcome.html 
* "Every little picofarad has a nanohenry all its own" -- Don Vonada
From 5b9663abdf95c386209b729708402f2d4d5aaf32 Mon Sep 17 00:00:00 2001
From: Christoph Baumann <[email protected]>
Date: Tue, 17 Nov 2026 09:50:30 +0100
Subject: [PATCH] avoid SIGSEGV when accessing Intel GPUs

 see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1140338
---
 src/common_vgaarb.c | 30 +++++++++++++++++++++++++-----
 1 file changed, 25 insertions(+), 5 deletions(-)

diff --git a/src/common_vgaarb.c b/src/common_vgaarb.c
index c0ca2f0..381e723 100644
--- a/src/common_vgaarb.c
+++ b/src/common_vgaarb.c
@@ -234,6 +234,8 @@ pci_device_vgaarb_set_target(struct pci_device *dev)
     char buf[BUFSIZE + 1]; /* reading BUFSIZE characters, + 1 for NULL */
     int ret;
 
+    if (!pci_sys)
+        return -1;
     if (!dev)
         dev = pci_sys->vga_default_dev;
     if (!dev)
@@ -265,8 +267,12 @@ pci_device_vgaarb_decodes(int new_vgaarb_rsrc)
     int len;
     char buf[BUFSIZE + 1]; /* reading BUFSIZE characters, + 1 for NULL */
     int ret;
-    struct pci_device *dev = pci_sys->vga_target;
+    struct pci_device *dev = NULL;
+
+    if (!pci_sys)
+        return -1;
 
+    dev = pci_sys->vga_target;
     if (!dev)
         return -1;
     if (dev->vgaarb_rsrc == new_vgaarb_rsrc)
@@ -296,10 +302,14 @@ pci_device_vgaarb_lock(void)
 {
     int len;
     char buf[BUFSIZE];
-    struct pci_device *dev = pci_sys->vga_target;
+    struct pci_device *dev = NULL;
 
+    if (!pci_sys)
+        return -1;
+
+    dev = pci_sys->vga_target;
     if (!dev)
-	return -1;
+        return -1;
 
     if (dev->vgaarb_rsrc == 0 || pci_sys->vga_count == 1)
         return 0;
@@ -316,8 +326,12 @@ pci_device_vgaarb_trylock(void)
 {
     int len;
     char buf[BUFSIZE];
-    struct pci_device *dev = pci_sys->vga_target;
+    struct pci_device *dev = NULL;
 
+    if (!pci_sys)
+        return -1;
+
+    dev = pci_sys->vga_target;
     if (!dev)
         return -1;
 
@@ -336,8 +350,12 @@ pci_device_vgaarb_unlock(void)
 {
     int len;
     char buf[BUFSIZE];
-    struct pci_device *dev = pci_sys->vga_target;
+    struct pci_device *dev = NULL;
+
+    if (!pci_sys)
+        return -1;
 
+    dev = pci_sys->vga_target;
     if (!dev)
         return -1;
 
@@ -353,6 +371,8 @@ pci_device_vgaarb_unlock(void)
 
 int pci_device_vgaarb_get_info(struct pci_device *dev, int *vga_count, int *rsrc_decodes)
 {
+    if (!pci_sys)
+        return -1;
     *vga_count = pci_sys->vga_count;
     if (!dev)
         return 0;
-- 
2.47.3

Reply via email to