On 10 July 2016 at 23:26, Eric Engestrom <e...@engestrom.ch> wrote:
> Coverity (CovID 1255672) noticed that all the other calls to drmGetMagic were
> checked for failure, but not this one. Fix this, and return before an invalid
> magic token is used to authenticate the device.
>
> Signed-off-by: Eric Engestrom <e...@engestrom.ch>
> ---
>  src/egl/drivers/dri2/platform_wayland.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/src/egl/drivers/dri2/platform_wayland.c 
> b/src/egl/drivers/dri2/platform_wayland.c
> index e714e44..9de75f2 100644
> --- a/src/egl/drivers/dri2/platform_wayland.c
> +++ b/src/egl/drivers/dri2/platform_wayland.c
> @@ -918,7 +918,10 @@ drm_handle_device(void *data, struct wl_drm *drm, const 
> char *device)
>     if (drmGetNodeTypeFromFd(dri2_dpy->fd) == DRM_NODE_RENDER) {
>        dri2_dpy->authenticated = 1;
>     } else {
> -      drmGetMagic(dri2_dpy->fd, &magic);
> +      if (drmGetMagic(dri2_dpy->fd, &magic)) {
> +         _eglLog(_EGL_WARNING, "wayland-egl: failed to get drm magic");
> +         return;
Missing close(fd) and free(device_name) ?
Then again... the whole error handing in the area seems fishy. Locally
we may open and/or allocate yet in dri2_initialize_wayland_drm() we
close/free unconditionally.

Mildly related:
- Is having the consecutive roundtrip()s needed/wise ?
- Are we doing a double auth... once in dri2_initialize_wayland_drm
(via drm_handle_device()) and second time in
dri2_bind_wayland_display_wl (via dri2_wl_authenticate).
Afaict it is not possible to have BindWaylandDisplayWL before
Initialize... and/or use BindWaylandDisplayWL without selecting (via
GetPlatformDisplay* or GetDisplay) a wayland dpy ?

Thanks
Emil
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to