From 13e2c356039ab5270174c9401c120bc9df5e23a6 Mon Sep 17 00:00:00 2001 From: Jonathan Gray Date: Mon, 13 May 2019 02:50:49 +1000 Subject: [PATCH] xf86drm: test for render nodes before primary nodes Unlike Linux the OpenBSD primary "drm" device name is substring of the "drmR" render node device name and strncmp() tests resulted in render nodes being flagged as primary nodes. Signed-off-by: Jonathan Gray Reviewed-by: Eric Engestrom Acked-by: Eric Engestrom --- xf86drm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xf86drm.c b/xf86drm.c index 953fc762..39a82063 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -3141,10 +3141,6 @@ drm_public int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b) static int drmGetNodeType(const char *name) { - if (strncmp(name, DRM_PRIMARY_MINOR_NAME, - sizeof(DRM_PRIMARY_MINOR_NAME) - 1) == 0) - return DRM_NODE_PRIMARY; - if (strncmp(name, DRM_CONTROL_MINOR_NAME, sizeof(DRM_CONTROL_MINOR_NAME ) - 1) == 0) return DRM_NODE_CONTROL; @@ -3153,6 +3149,10 @@ static int drmGetNodeType(const char *name) sizeof(DRM_RENDER_MINOR_NAME) - 1) == 0) return DRM_NODE_RENDER; + if (strncmp(name, DRM_PRIMARY_MINOR_NAME, + sizeof(DRM_PRIMARY_MINOR_NAME) - 1) == 0) + return DRM_NODE_PRIMARY; + return -EINVAL; }