Module: Mesa
Branch: master
Commit: 38cec0303be9ef79facbb2c8f73eb6a2f77e82ca
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=38cec0303be9ef79facbb2c8f73eb6a2f77e82ca

Author: Emil Velikov <[email protected]>
Date:   Fri Nov  7 03:33:56 2014 +0000

egl_dri2: fix double free on drm platforms

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.

v2:
 - Drop the ifdef HAVE_DRM_PLATFORM, reindent the code and fix the
comment block. Suggested by Ken.

Reported-by: Kenneth Graunke <[email protected]>
Reported-by: Mark Janes <[email protected]>
Signed-off-by: Emil Velikov <[email protected]>
Reviewed-and-tested-by: Kenneth Graunke <[email protected]> (v1)

---

 src/egl/drivers/dri2/egl_dri2.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index dcc3239..eceaf1a 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -707,9 +707,15 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
       break;
    }
 
-   for (i = 0; dri2_dpy->driver_configs[i]; i++)
-      free((__DRIconfig *) dri2_dpy->driver_configs[i]);
-   free(dri2_dpy->driver_configs);
+   /* 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.
+    */
+   if (disp->Platform != _EGL_PLATFORM_DRM) {
+      for (i = 0; dri2_dpy->driver_configs[i]; i++)
+         free((__DRIconfig *) dri2_dpy->driver_configs[i]);
+      free(dri2_dpy->driver_configs);
+   }
    free(dri2_dpy);
    disp->DriverData = NULL;
 

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to