backend-vnc: Remove the display when output is disabled

This prevents a potential abort yelling:

PANIC: ../subprojects/neatvnc/src/server.c: 2245: Multiple displays are not implemented. Aborting!

which happens because we never unregister the output, a mirror function
for nvnc_add_display().

Further more, we migrate nvc_close() to vnc_destroy() and check for
a valid output in vnc_client_cleanup(). Having a single caller in
vnc_shutdown() (which was migrated) we removed that entirely. Necessary
to avoid a use-after-free caused by nvc_close().

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
Marius Vlad 2024-07-03 18:32:51 +03:00
parent 376b3952a0
commit f22ca6aecc
1 changed files with 4 additions and 10 deletions

View File

@ -498,7 +498,7 @@ vnc_client_cleanup(struct nvnc_client *client)
free(peer);
weston_log("VNC Client disconnected\n");
if (wl_list_empty(&output->peers))
if (output && wl_list_empty(&output->peers))
weston_output_power_off(&output->base);
}
@ -868,6 +868,7 @@ vnc_output_disable(struct weston_output *base)
if (!output->base.enabled)
return 0;
nvnc_remove_display(backend->server, output->display);
nvnc_display_unref(output->display);
nvnc_fb_pool_unref(output->fb_pool);
@ -928,14 +929,6 @@ vnc_create_output(struct weston_backend *backend, const char *name)
return &output->base;
}
static void
vnc_shutdown(struct weston_backend *base)
{
struct vnc_backend *backend = container_of(base, struct vnc_backend, base);
nvnc_close(backend->server);
}
static void
vnc_destroy(struct weston_backend *base)
{
@ -943,6 +936,8 @@ vnc_destroy(struct weston_backend *base)
struct weston_compositor *ec = backend->compositor;
struct weston_head *head, *next;
nvnc_close(backend->server);
wl_list_remove(&backend->base.link);
wl_event_source_remove(backend->aml_event);
@ -1150,7 +1145,6 @@ vnc_backend_create(struct weston_compositor *compositor,
wl_list_init(&backend->base.link);
backend->compositor = compositor;
backend->base.shutdown = vnc_shutdown;
backend->base.destroy = vnc_destroy;
backend->base.create_output = vnc_create_output;
backend->vnc_monitor_refresh_rate = config->refresh_rate * 1000;