From 381e2a9405ed939c5774d9c582298c661139d0c5 Mon Sep 17 00:00:00 2001
From: duerpei <duep.fnst@fujitsu.com>
Date: Mon, 28 Feb 2022 16:08:10 +0800
Subject: [PATCH] Fix potential memory leak
MIME-Version: 1.0
Content-Type: text/plain; charset=utf8
Content-Transfer-Encoding: 8bit

Bug-AGL:SPEC-4259

Signed-off-by: duerpei <duep.fnst@fujitsu.com>
Change-Id: I4be57103eee67d64893baccf878d2dbebd1f9cf5
Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/27219
Reviewed-by: Marius Vlad <marius.vlad@collabora.com>
Reviewed-by: Naoto YAMAGUCHI <naoto.yamaguchi@aisin.co.jp>
Reviewed-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org>
Tested-by: Jenkins Job builder account
ci-image-build: Jenkins Job builder account
ci-image-boot-test: Jenkins Job builder account
---
 ...emove-source-repaint_timer-in-weston_comp.patch | 34 ++++++++++++++++++++++
 .../wayland/weston_8.0_aglcore.inc                 |  1 +
 2 files changed, 35 insertions(+)
 create mode 100644 meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Remove-source-repaint_timer-in-weston_comp.patch

diff --git a/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Remove-source-repaint_timer-in-weston_comp.patch b/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Remove-source-repaint_timer-in-weston_comp.patch
new file mode 100644
index 000000000..bdcc249e2
--- /dev/null
+++ b/meta-agl-core/recipes-graphics/wayland/weston/0001-libweston-Remove-source-repaint_timer-in-weston_comp.patch
@@ -0,0 +1,34 @@
+From d4b46cdd3cf0b7e9eaa415fc87a4281695f2349c Mon Sep 17 00:00:00 2001
+From: Lujin Wang <luwang@nvidia.com>
+Date: Mon, 12 Aug 2019 12:03:29 -0700
+Subject: [PATCH] libweston: Remove source repaint_timer in
+ weston_compositor_shutdown
+
+Fixes a definitely lost:
+== 56 bytes in 1 blocks are definitely lost in loss record 16 of 45
+==    at 0x48450F8: malloc (vg_replace_malloc.c:309)
+==    by 0x4B55E93: wl_event_loop_add_timer (event-loop.c:197)
+==    by 0x4126CF: weston_compositor_create (in /usr/local/bin/weston)
+==    by 0x409997: main (in /usr/local/bin/weston)
+
+Signed-off-by: Lujin Wang <luwang@nvidia.com>
+Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
+---
+ libweston/compositor.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/libweston/compositor.c b/libweston/compositor.c
+index c2da3a48c..90321e860 100644
+--- a/libweston/compositor.c
++++ b/libweston/compositor.c
+@@ -7733,6 +7733,7 @@ weston_compositor_shutdown(struct weston_compositor *ec)
+ 	struct weston_output *output, *next;
+ 
+ 	wl_event_source_remove(ec->idle_source);
++	wl_event_source_remove(ec->repaint_timer);
+ 
+ 	/* Destroy all outputs associated with this compositor */
+ 	wl_list_for_each_safe(output, next, &ec->output_list, link)
+-- 
+GitLab
+
diff --git a/meta-agl-core/recipes-graphics/wayland/weston_8.0_aglcore.inc b/meta-agl-core/recipes-graphics/wayland/weston_8.0_aglcore.inc
index 71d27005a..f970d5f23 100644
--- a/meta-agl-core/recipes-graphics/wayland/weston_8.0_aglcore.inc
+++ b/meta-agl-core/recipes-graphics/wayland/weston_8.0_aglcore.inc
@@ -6,6 +6,7 @@ SRC_URI:append = "\
     file://0001-clients-window-Add-set_app_id-function-change-Waylan.patch \
     file://0001-libweston-backend-drm-Re-order-gbm-destruction-at-DR.patch \
     file://0001-gl-renderer-Avoid-double-free-on-init-failure.patch \
+    file://0001-libweston-Remove-source-repaint_timer-in-weston_comp.patch \
     "
 
 # Workaround for incorrect upstream definition
-- 
2.16.6