summaryrefslogtreecommitdiffstats
path: root/meta-agl-core/recipes-graphics/wayland/weston/0002-libweston-desktop-introduce-weston_desktop_client_de.patch
diff options
context:
space:
mode:
authorduerpei <duep.fnst@fujitsu.com>2022-03-14 13:27:43 +0800
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2022-03-18 10:17:05 +0000
commit4c2a3dbe7b652e679c9228d7d8c81aa641bd968b (patch)
tree14f974ce012b6e76c5680ed624633e5d2d9b9ac1 /meta-agl-core/recipes-graphics/wayland/weston/0002-libweston-desktop-introduce-weston_desktop_client_de.patch
parent7d671af1dc9bc1d1e70a113a2e4a84e63a141814 (diff)
Fix potential memory leak of two pointers (xwayland and client)
This backports four patches from weston to solve a memory leak problem These four patches are: https://gitlab.freedesktop.org/wayland/weston/-/commit/5a6604a7a2e52e5cd84c1f53724b3f7c325b5dff.patch https://gitlab.freedesktop.org/wayland/weston/-/commit/f53c05d3c2c19c139c52e9bd621c2654dd3dac69.patch https://gitlab.freedesktop.org/wayland/weston/-/commit/e2583ca0844bd7a8ce4fc94da9ad67edf49ffd45.patch https://gitlab.freedesktop.org/wayland/weston/-/commit/8740037a93c7c4400cc381ecf3009d1e4014be07.patch The following is the valgrind log: 160 bytes in 1 blocks are definitely lost in loss record 39 of 66 at 0x484B64C: calloc (in /usr/lib/valgrind/vgpreload_memcheck-arm64-linux.so) by 0x4A73C87: ??? (in /usr/lib/libweston-desktop-8.so.0.0.0) by 0x4A7184F: weston_desktop_create (in /usr/lib/libweston-desktop-8.so.0.0.0) by 0x487096B: ivi_desktop_init (in /usr/lib/agl-compositor/libexec_compositor.so.0.0.0) by 0x486F5E7: wet_main (in /usr/lib/agl-compositor/libexec_compositor.so.0.0.0) by 0x48B010F: (below main) (in /lib/libc-2.31.so) In agl-compositor/src/composiotr.c "ivi->desktop->compositor->xwayland" is zalloced by wet_main()->ivi_desktop_init()->weston_desktop_create()->weston_desktop_xwayland_init() "ivi->desktop->compositor->xwayland->client" is zalloced by wet_main()->ivi_desktop_init()->weston_desktop_create()->weston_desktop_xwayland_init()->weston_desktop_client_create() "ivi->desktop->compositor->xwayland" and "ivi->desktop->compositor->xwayland->client" The memory pointed to has not been released Now, I want to free the memory pointed by the two pointers. What can do this is the function of weston_desktop_xwayland_fini() in 0003-libweston-desktop-add-weston_desktop_xwayland_fini.patch And the submission of this patch depends on the first three patches, so I submitted these four patches. Bug-AGL: SPEC-4291 Signed-off-by: duerpei <duep.fnst@fujitsu.com> Change-Id: I3b1140e88eadad9e378c2bb43221026e280ecd90 Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/27257 Reviewed-by: Marius Vlad <marius.vlad@collabora.com> Reviewed-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> Tested-by: Jenkins Job builder account
Diffstat (limited to 'meta-agl-core/recipes-graphics/wayland/weston/0002-libweston-desktop-introduce-weston_desktop_client_de.patch')
-rw-r--r--meta-agl-core/recipes-graphics/wayland/weston/0002-libweston-desktop-introduce-weston_desktop_client_de.patch88
1 files changed, 88 insertions, 0 deletions
diff --git a/meta-agl-core/recipes-graphics/wayland/weston/0002-libweston-desktop-introduce-weston_desktop_client_de.patch b/meta-agl-core/recipes-graphics/wayland/weston/0002-libweston-desktop-introduce-weston_desktop_client_de.patch
new file mode 100644
index 000000000..229c8506a
--- /dev/null
+++ b/meta-agl-core/recipes-graphics/wayland/weston/0002-libweston-desktop-introduce-weston_desktop_client_de.patch
@@ -0,0 +1,88 @@
+From f53c05d3c2c19c139c52e9bd621c2654dd3dac69 Mon Sep 17 00:00:00 2001
+From: Pekka Paalanen <pekka.paalanen@collabora.com>
+Upstream-Status: Backport
+Date: Fri, 14 May 2021 16:04:45 +0300
+Subject: [PATCH] libweston-desktop: introduce weston_desktop_client_destroy()
+
+This new function is callable explicitly, unlike the old function that
+used to have the same name.
+
+This will be needed when tearing down what
+weston_desktop_xwayland_init() puts up.
+
+Since calling weston_desktop_client_destroy() for an external client
+(one that has a wl_resource for this) is a bug, add asserts to prevent
+it. This will only be needed for the internal client: XWM.
+
+Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
+---
+ libweston-desktop/client.c | 21 +++++++++++++++++----
+ libweston-desktop/internal.h | 2 ++
+ 2 files changed, 19 insertions(+), 4 deletions(-)
+
+diff --git a/libweston-desktop/client.c b/libweston-desktop/client.c
+index ba7bfbc46..44718e2db 100644
+--- a/libweston-desktop/client.c
++++ b/libweston-desktop/client.c
+@@ -24,6 +24,7 @@
+ #include "config.h"
+
+ #include <wayland-server.h>
++#include <assert.h>
+
+ #include <libweston/libweston.h>
+ #include <libweston/zalloc.h>
+@@ -48,14 +49,14 @@ weston_desktop_client_add_destroy_listener(struct weston_desktop_client *client,
+ wl_signal_add(&client->destroy_signal, listener);
+ }
+
+-static void
+-weston_desktop_client_handle_destroy(struct wl_resource *resource)
++void
++weston_desktop_client_destroy(struct weston_desktop_client *client)
+ {
+- struct weston_desktop_client *client =
+- wl_resource_get_user_data(resource);
+ struct wl_list *list = &client->surface_list;
+ struct wl_list *link, *tmp;
+
++ assert(client->resource == NULL);
++
+ wl_signal_emit(&client->destroy_signal, client);
+
+ for (link = list->next, tmp = link->next;
+@@ -71,6 +72,18 @@ weston_desktop_client_handle_destroy(struct wl_resource *resource)
+ free(client);
+ }
+
++static void
++weston_desktop_client_handle_destroy(struct wl_resource *resource)
++{
++ struct weston_desktop_client *client =
++ wl_resource_get_user_data(resource);
++
++ assert(client->resource == resource);
++ client->resource = NULL;
++
++ weston_desktop_client_destroy(client);
++}
++
+ static int
+ weston_desktop_client_ping_timeout(void *user_data)
+ {
+diff --git a/libweston-desktop/internal.h b/libweston-desktop/internal.h
+index e4ab2701b..7a815bd87 100644
+--- a/libweston-desktop/internal.h
++++ b/libweston-desktop/internal.h
+@@ -134,6 +134,8 @@ weston_desktop_client_create(struct weston_desktop *desktop,
+ const struct wl_interface *interface,
+ const void *implementation, uint32_t version,
+ uint32_t id);
++void
++weston_desktop_client_destroy(struct weston_desktop_client *client);
+
+ void
+ weston_desktop_client_add_destroy_listener(struct weston_desktop_client *client,
+--
+GitLab
+