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 <p.zabel@pengutronix.de>
This commit is contained in:
parent
463ebda4e4
commit
1ffcc535ef
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue