From 1e3395a626a38727f3b1f76e4648c229411840ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michel=20D=C3=A4nzer?= Date: Wed, 12 Jun 2019 17:58:50 +0200 Subject: [PATCH libdrm] amdgpu: Compare DRM node type as well in fd_compare MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Re-using a device for a node type different from the one passed in can break. Bugzilla: https://bugs.freedesktop.org/110903 Signed-off-by: Michel Dänzer --- amdgpu/amdgpu_device.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c index 362494b1..827d392b 100644 --- a/amdgpu/amdgpu_device.c +++ b/amdgpu/amdgpu_device.c @@ -50,9 +50,11 @@ static int fd_compare(int fd1, int fd2) { char *name1 = drmGetPrimaryDeviceNameFromFd(fd1); char *name2 = drmGetPrimaryDeviceNameFromFd(fd2); + int type1 = drmGetNodeTypeFromFd(fd1); + int type2 = drmGetNodeTypeFromFd(fd2); int result; - if (name1 == NULL || name2 == NULL) { + if (name1 == NULL || name2 == NULL || type1 == -1 || type2 == -1) { free(name1); free(name2); return 0; @@ -62,7 +64,10 @@ static int fd_compare(int fd1, int fd2) free(name1); free(name2); - return result; + if (result) + return result; + + return type1 != type2; } /** -- 2.20.1