diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2023-07-06 07:21:31 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2023-07-06 07:21:31 +0000 |
commit | 1a651e88cc8ffc251cd14a6c4387735141a904ee (patch) | |
tree | 55129e083e382887374b8c2d6109bf5aaf6d4443 /lib/libdrm/xf86drm.c | |
parent | 26d75171bf61606af8c67347ab39a45dc6aae78a (diff) |
fix drmGetMinorNameForFD(). tweaks and ok jsg@.
For the gpu n, the main device node is /dev/dri/card<n> and the
render device node is /dev/dri/renderD<n+drmGetMinorBase()> not
/dev/dri/renderD<n>
and miod@ checked that no port should be affected.
Diffstat (limited to 'lib/libdrm/xf86drm.c')
-rw-r--r-- | lib/libdrm/xf86drm.c | 8 |
1 files 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; |