From 677cd97dc4a930af508388713f5016baf664ed18 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Fri, 21 Oct 2016 10:07:59 -0700 Subject: [PATCH] Return an -ENODEV from drmGetDevice() when no device was found. Fixes crashes in Mesa on platform devices, which expected *device to have a device when 0 was returned. (code from a paste by Rob, commit message by anholt) Signed-off-by: Eric Anholt Reviewed-by: Alex Deucher Reviewed-by: Emil Velikov --- xf86drm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xf86drm.c b/xf86drm.c index 9cfca49d..9b52889e 100644 --- a/xf86drm.c +++ b/xf86drm.c @@ -3181,6 +3181,8 @@ int drmGetDevice(int fd, drmDevicePtr *device) closedir(sysdir); free(local_devices); + if (*device == NULL) + return -ENODEV; return 0; free_devices: