diff mbox

[libdrm,1/2] Return an -ENODEV from drmGetDevice() when no device was found.

Message ID 20161021171240.6972-1-eric@anholt.net
State New
Headers show

Commit Message

Eric Anholt Oct. 21, 2016, 5:12 p.m. UTC
From: Rob Herring <robh@kernel.org>

Fixes crashes in Mesa on platform device, 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>
---
 xf86drm.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Alex Deucher Oct. 21, 2016, 5:32 p.m. UTC | #1
On Fri, Oct 21, 2016 at 1:12 PM, Eric Anholt <eric@anholt.net> wrote:
> glxgears was spamming this 12 times at startup because of Mesa's
> probing of the DRM device code, which doesn't support platform
> devices.
>
> Signed-off-by: Eric Anholt <eric@anholt.net>

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  xf86drm.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/xf86drm.c b/xf86drm.c
> index 9b52889e4cef..52add5e441d7 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -3149,7 +3149,6 @@ int drmGetDevice(int fd, drmDevicePtr *device)
>
>              break;
>          default:
> -            fprintf(stderr, "The subsystem type is not supported yet\n");
>              continue;
>          }
>
> @@ -3259,7 +3258,6 @@ int drmGetDevices(drmDevicePtr devices[], int max_devices)
>
>              break;
>          default:
> -            fprintf(stderr, "The subsystem type is not supported yet\n");
>              continue;
>          }
>
> --
> 2.9.3
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/xf86drm.c b/xf86drm.c
index 9cfca49ddfda..9b52889e4cef 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: