From 508791166c2012c8cd1d85661872e64ec6f733d7 Mon Sep 17 00:00:00 2001 From: matthieu Date: Thu, 6 Jul 2023 07:21:30 +0000 Subject: [PATCH] fix drmGetMinorNameForFD(). tweaks and ok jsg@. For the gpu n, the main device node is /dev/dri/card and the render device node is /dev/dri/renderD not /dev/dri/renderD and miod@ checked that no port should be affected. --- lib/libdrm/xf86drm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/libdrm/xf86drm.c b/lib/libdrm/xf86drm.c index f589eb1ab..e61e3e88c 100644 --- a/lib/libdrm/xf86drm.c +++ b/lib/libdrm/xf86drm.c @@ -846,7 +846,7 @@ static int _priv_open_device(const char *path) { drmMsg("_priv_open_device\n"); - return open(path, O_RDWR, 0); + return open(path, O_RDWR); } drm_public int priv_open_device(const char *) @@ -3539,6 +3539,10 @@ static char *drmGetMinorNameForFD(int fd, int type) const char *dev_name = drmGetDeviceName(type); unsigned int maj, min; int n; + int base = drmGetMinorBase(type); + + if (base < 0) + return NULL; if (fstat(fd, &sbuf)) return NULL; @@ -3552,7 +3556,7 @@ static char *drmGetMinorNameForFD(int fd, int type) if (!dev_name) return NULL; - n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, min); + n = snprintf(buf, sizeof(buf), dev_name, DRM_DIR_NAME, base + min); if (n == -1 || n >= sizeof(buf)) return NULL;