OSDN Git Service

Return an -ENODEV from drmGetDevice() when no device was found.
authorRob Herring <robh@kernel.org>
Fri, 21 Oct 2016 17:07:59 +0000 (10:07 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 21 Oct 2016 19:50:50 +0000 (12:50 -0700)
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 <eric@anholt.net>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
xf86drm.c

index 9cfca49..9b52889 100644 (file)
--- 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: