From da8a57809e4b58b3b8d8b3baab85aa2e08b75270 Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Sat, 13 Sep 2025 13:17:40 +0300 Subject: [PATCH] fbdevhw: don't reject pci devices on the fallback probe Now that we know the root couse of what this code tried to fix, we can safely remove it. Fixes: https://gitlab.freedesktop.org/xorg/driver/xf86-video-fbdev/-/issues/9 Fixes: https://gitlab.freedesktop.org/xorg/xserver/-/commit/fc78bcca21e767697de6ad4d8e03b6728856f613 Fixes: https://gitlab.freedesktop.org/xorg/xserver/-/commit/a8e41a81909ef74faa38ef12ca35c5d83f7c56a5 Fixes: https://gitlab.freedesktop.org/xorg/xserver/-/commit/728b54528d37ffa27b07c9b181c5ed8d2d359379 Fixes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1798 Fixes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1826 Signed-off-by: stefan11111 --- hw/xfree86/fbdevhw/fbdevhw.c | 61 +----------------------------------- 1 file changed, 1 insertion(+), 60 deletions(-) diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c index 95ea7096ff..0cb19724aa 100644 --- a/hw/xfree86/fbdevhw/fbdevhw.c +++ b/hw/xfree86/fbdevhw/fbdevhw.c @@ -338,31 +338,6 @@ fbdev_open_pci(int scrnIndex, struct pci_device *pPci, const char *device, char return -1; } -/* * - * Try to resolve a filename as symbolic link. If the file is not a link, the - * original filename is returned. NULL is returned if readlink raised an - * error. - */ -static const char * -resolve_link(const char *filename, char *resolve_buf, size_t resolve_buf_size) -{ - ssize_t len = readlink(filename, resolve_buf, resolve_buf_size - 1); - /* if it is a link resolve it */ - if (len >= 0) { - resolve_buf[len] = '\0'; - return resolve_buf; - } - else { - if (errno == EINVAL) { - return filename; - } - else { - /* Have caller handle error condition */ - return NULL; - } - } -} - static int fbdev_open(int scrnIndex, const char *dev, char **namep) { @@ -371,7 +346,7 @@ fbdev_open(int scrnIndex, const char *dev, char **namep) fd = check_user_devices(scrnIndex, dev, namep); if (fd != -1) { - /* fbdev was provided by the user and not guessed, skip non-pci check */ + /* fbdev was provided by the user and not guessed, just return it */ return fd; } @@ -391,40 +366,6 @@ fbdev_open(int scrnIndex, const char *dev, char **namep) return -1; } - /* only touch non-PCI devices on this path */ - /* TODO: Should we keep doing this? */ - { - char device_path_buf[PATH_MAX]; - char buf[PATH_MAX] = {0}; - char *sysfs_path = NULL; - char const *real_dev = resolve_link(dev, device_path_buf, - sizeof(device_path_buf)); - if (real_dev == NULL) { - xf86DrvMsg(scrnIndex, X_ERROR, - "Failed resolving symbolic link for device '%s': %s", - dev, strerror(errno)); - return -1; - } - - const char *node = strrchr(real_dev, '/'); - - if (node == NULL) { - node = real_dev; - } - else { - node++; - } - - if (asprintf(&sysfs_path, "/sys/class/graphics/%s/device/subsystem", node) < 0 || - readlink(sysfs_path, buf, sizeof(buf) - 1) < 0 || - strstr(buf, "bus/pci")) { - free(sysfs_path); - close(fd); - return -1; - } - free(sysfs_path); - } - return set_name(scrnIndex, fd, namep, TRUE, TRUE); }