[Mesa-dev] [PATCH 1/3] egl_dri2: fix double free on drm platforms

Kenneth Graunke kenneth at whitecape.org
Thu Nov 6 23:55:41 PST 2014


On Friday, November 07, 2014 03:50:42 AM Emil Velikov wrote:
> Earlier commit failed to attribure that for drm platforms one does not
> call dri2_create_screen, thus it does not create the screen and
> driver_configs but inherits them from the "display" - gbm.
> 
> As such wrap cleanup in Platform != _EGL_PLATFORM_DRM to prevent
> the issue and still cleanup correctly for non-drm platforms.
> 
> Cc: Kenneth Graunke <kenneth at whitecape.org>
> Cc: Mark Janes <mark.a.janes at intel.com>
> Reported-by: Kenneth Graunke <kenneth at whitecape.org>
> Reported-by: Mark Janes <mark.a.janes at intel.com>
> Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
> ---
>  src/egl/drivers/dri2/egl_dri2.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/src/egl/drivers/dri2/egl_dri2.c 
b/src/egl/drivers/dri2/egl_dri2.c
> index dcc3239..609afde 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -707,9 +707,18 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
>        break;
>     }
>  
> +   /* The drm platform does not create the screen/driver_configs but reuses
> +    * the ones from the gbm device. As such the gbm itself is responsible
> +    * for the cleanup. */

Usually */ goes on its own line (same applies to later patches).

> +#ifdef HAVE_DRM_PLATFORM

I don't think you need these #ifdefs - _EGL_PLATFORM_DRM is an enum value 
defined by src/egl/main/egldisplay.h (not the public EGL headers) regardless 
of build options.  I imagine if you didn't build with HAVE_DRM_PLATFORM, disp-
>Platform will never be _EGL_PLATFORM_DRM.

> +   if (disp->Platform != _EGL_PLATFORM_DRM) {
> +#endif
>     for (i = 0; dri2_dpy->driver_configs[i]; i++)
>        free((__DRIconfig *) dri2_dpy->driver_configs[i]);
>     free(dri2_dpy->driver_configs);
> +#ifdef HAVE_DRM_PLATFORM
> +   }
> +#endif
>     free(dri2_dpy);
>     disp->DriverData = NULL;

Thanks for fixing this so quickly!  The series fixes my crashes, and is:
Reviewed-and-tested-by: Kenneth Graunke <kenneth at whitecape.org>

with, of course, the caveat that I don't know the EGL code worth beans. :)

--Ken
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20141106/f17aff04/attachment.sig>


More information about the mesa-dev mailing list