summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2018-10-10 14:09:11 -0400
committerAdam Jackson <ajax@redhat.com>2018-10-12 11:35:42 -0400
commitf5dc787fc9bb102e4eea477d1817e35370084ea2 (patch)
treebdfa227dd6ad4aef860add822c5dfed47e7ba2b5
parent4795c069a503144ea31f01de0c039f32d9880292 (diff)
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 <ajax@redhat.com> (cherry picked from commit fc78bcca21e767697de6ad4d8e03b6728856f613)
-rw-r--r--hw/xfree86/fbdevhw/fbdevhw.c16
1 files changed, 16 insertions, 0 deletions
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;