From 1ffcc535ef5d718a72832d1c90927032ee10fb77 Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 13 Jul 2023 17:36:06 +0200 Subject: [PATCH] hmi-controller: Do not call hmi_controller_destroy() from _create() Move the destroy listener registration to the top, to avoid having to call hmi_controller_destroy() for cleanup when it fails. This would segfault trying to remove the destroy listener from a list when its link was never initialized or inserted into any list. The failure case can be hit by setting both modules=hmi-controller.so in weston.ini and --modules=hmi-controller.so on the command line. Signed-off-by: Philipp Zabel --- ivi-shell/hmi-controller.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ivi-shell/hmi-controller.c b/ivi-shell/hmi-controller.c index a7ed6626..279e2471 100644 --- a/ivi-shell/hmi-controller.c +++ b/ivi-shell/hmi-controller.c @@ -923,6 +923,13 @@ hmi_controller_create(struct weston_compositor *ec) } hmi_ctrl = xzalloc(sizeof(*hmi_ctrl)); + + if(interface->shell_add_destroy_listener_once(&hmi_ctrl->destroy_listener, + hmi_controller_destroy) == IVI_FAILED){ + free(hmi_ctrl); + return NULL; + } + i = 0; wl_array_init(&hmi_ctrl->ui_widgets); @@ -1035,13 +1042,6 @@ hmi_controller_create(struct weston_compositor *ec) hmi_ctrl->input_panel_update.notify = set_notification_update_input_panel; hmi_ctrl->interface->add_listener_update_input_panel(&hmi_ctrl->input_panel_update); - if(hmi_ctrl->interface->shell_add_destroy_listener_once(&hmi_ctrl->destroy_listener, - hmi_controller_destroy) == IVI_FAILED){ - hmi_controller_destroy(&hmi_ctrl->destroy_listener, NULL); - return NULL; - } - - return hmi_ctrl; }