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 <eric@anholt.net>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
main
Rob Herring 2016-10-21 10:07:59 -07:00 committed by Eric Anholt
parent 7dd28475f1
commit 677cd97dc4
1 changed files with 2 additions and 0 deletions

View File

@ -3181,6 +3181,8 @@ int drmGetDevice(int fd, drmDevicePtr *device)
closedir(sysdir); closedir(sysdir);
free(local_devices); free(local_devices);
if (*device == NULL)
return -ENODEV;
return 0; return 0;
free_devices: free_devices: