From f5dc787fc9bb102e4eea477d1817e35370084ea2 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Wed, 10 Oct 2018 14:09:11 -0400 Subject: [PATCH] fbdevhw: Refuse to touch PCI devices on the fallback probe path Fixes: https://gitlab.freedesktop.org/xorg/driver/xf86-video-fbdev/issues/9 Signed-off-by: Adam Jackson (cherry picked from commit fc78bcca21e767697de6ad4d8e03b6728856f613) --- hw/xfree86/fbdevhw/fbdevhw.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hw/xfree86/fbdevhw/fbdevhw.c b/hw/xfree86/fbdevhw/fbdevhw.c index 0bd77df87..3fb1d2bba 100644 --- a/hw/xfree86/fbdevhw/fbdevhw.c +++ b/hw/xfree86/fbdevhw/fbdevhw.c @@ -329,6 +329,22 @@ fbdev_open(int scrnIndex, const char *dev, char **namep) return -1; } + /* only touch non-PCI devices on this path */ + { + char buf[PATH_MAX]; + char *sysfs_path = NULL; + char *node = strrchr(dev, '/') + 1; + + if (asprintf(&sysfs_path, "/sys/class/graphics/%s", node) < 0 || + readlink(sysfs_path, buf, sizeof(buf) < 0) || + strstr(buf, "devices/pci")) { + free(sysfs_path); + close(fd); + return -1; + } + free(sysfs_path); + } + if (namep) { if (-1 == ioctl(fd, FBIOGET_FSCREENINFO, (void *) (&fix))) { *namep = NULL;