[PATCH] compositor-drm: free drm_mode in drm_output_destroy

Xiong Zhang xiong.y.zhang at intel.com
Sun Dec 15 23:23:43 PST 2013


When drm_output is destroyed, we should free drm_mode to avoid
memoey leakage.

Signed-off-by: Xiong Zhang <xiong.y.zhang at intel.com>
---
 src/compositor-drm.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index fbf6e49..9af8f8d 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -1111,6 +1111,7 @@ drm_output_destroy(struct weston_output *output_base)
 	struct drm_compositor *c =
 		(struct drm_compositor *) output->base.compositor;
 	drmModeCrtcPtr origcrtc = output->original_crtc;
+	struct drm_mode *drm_mode, *next;
 
 	if (output->page_flip_pending) {
 		output->destroy_pending = 1;
@@ -1148,6 +1149,12 @@ drm_output_destroy(struct weston_output *output_base)
 	weston_output_destroy(&output->base);
 	wl_list_remove(&output->base.link);
 
+	wl_list_for_each_safe(drm_mode, next, &output->base.mode_list,
+			      base.link) {
+		wl_list_remove(&drm_mode->base.link);
+		free(drm_mode);
+	}
+
 	free(output);
 }
 
-- 
1.8.3.2



More information about the wayland-devel mailing list