summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-12-13 14:43:48 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-12-13 15:29:05 +0100
commit2649b7167affe98288dc0e4bdcd6909b8f655b77 (patch)
tree23a78a47aaa6b1d0651e81eccc71b966194da9e5
parent23895cc006f3dbf96a502ddd15e291e071aff25a (diff)
egl_dri2: Fix some valigrind reported leaksleak
Free the device_name, reported by Pekka Paalanen. Destroy wayland display and drm resources, if created by dri2_initialize_wayland.
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c9
-rw-r--r--src/egl/drivers/dri2/egl_dri2.h2
-rw-r--r--src/egl/drivers/dri2/platform_drm.c2
-rw-r--r--src/egl/drivers/dri2/platform_wayland.c5
4 files changed, 10 insertions, 8 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 44c9bc18d6..4c9ece351a 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -608,6 +608,8 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
close(dri2_dpy->fd);
if (dri2_dpy->driver)
dlclose(dri2_dpy->driver);
+ if (dri2_dpy->device_name)
+ free(dri2_dpy->device_name);
if (disp->PlatformDisplay == NULL) {
switch (disp->Platform) {
@@ -616,14 +618,9 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
xcb_disconnect(dri2_dpy->conn);
break;
#endif
-#ifdef HAVE_WAYLAND_PLATFORM
- case _EGL_PLATFORM_WAYLAND:
- wl_display_destroy(dri2_dpy->wl_dpy);
- break;
-#endif
#ifdef HAVE_DRM_PLATFORM
case _EGL_PLATFORM_DRM:
- if (dri2_dpy->own_gbm_device) {
+ if (dri2_dpy->own_device) {
gbm_device_destroy(&dri2_dpy->gbm_dri->base.base);
}
break;
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 95b87b8750..193a866324 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -101,9 +101,9 @@ struct dri2_egl_display
__DRIimageExtension *image;
int fd;
+ int own_device;
#ifdef HAVE_DRM_PLATFORM
struct gbm_dri_device *gbm_dri;
- int own_gbm_device;
#endif
char *device_name;
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index e2c8dab16b..3dc2c40c4e 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -108,7 +108,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
gbm = disp->PlatformDisplay;
if (gbm == NULL) {
fd = open("/dev/dri/card0", O_RDWR);
- dri2_dpy->own_gbm_device = 1;
+ dri2_dpy->own_device = 1;
gbm = gbm_create_device(fd);
if (gbm == NULL)
return EGL_FALSE;
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 7a70d8d590..16c613f30d 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -731,6 +731,10 @@ dri2_terminate(_EGLDriver *drv, _EGLDisplay *disp)
close(dri2_dpy->fd);
dlclose(dri2_dpy->driver);
free(dri2_dpy->driver_name);
+ free(dri2_dpy->device_name);
+ wl_drm_destroy(dri2_dpy->wl_drm);
+ if (dri2_dpy->own_device)
+ wl_display_destroy(dri2_dpy->wl_dpy);
free(dri2_dpy);
disp->DriverData = NULL;
@@ -819,6 +823,7 @@ dri2_initialize_wayland(_EGLDriver *drv, _EGLDisplay *disp)
dri2_dpy->wl_dpy = wl_display_connect(NULL);
if (dri2_dpy->wl_dpy == NULL)
goto cleanup_dpy;
+ dri2_dpy->own_device = 1;
} else {
dri2_dpy->wl_dpy = disp->PlatformDisplay;
}