[PATCH weston] compositor-drm: Fix crash when setting up seat constrained by an output

Ander Conselvan de Oliveira conselvan2 at gmail.com
Thu Apr 17 03:08:45 PDT 2014


From: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>

Commit 58e15865 changed the parameters for udev_get_seat_by_name() to
receive a struct udev_input. However, when this gets called from
create_output_from_connector() during initialization, the input struct
is not yet initialized, leading to a crash. Previously, that function
would take only a pointer to the compositor.

This patch fixes the crash by initializing input before creating any
outputs.

https://bugs.freedesktop.org/show_bug.cgi?id=77503
---
 src/compositor-drm.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 3c15ec3..9a4b311 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -2783,9 +2783,15 @@ drm_compositor_create(struct wl_display *display,
 	wl_list_init(&ec->sprite_list);
 	create_sprites(ec);
 
+	if (udev_input_init(&ec->input,
+			    &ec->base, ec->udev, param->seat_id) < 0) {
+		weston_log("failed to create input devices\n");
+		goto err_sprite;
+	}
+
 	if (create_outputs(ec, param->connector, drm_device) < 0) {
 		weston_log("failed to create output for %s\n", path);
-		goto err_sprite;
+		goto err_udev_input;
 	}
 
 	/* A this point we have some idea of whether or not we have a working
@@ -2795,12 +2801,6 @@ drm_compositor_create(struct wl_display *display,
 
 	path = NULL;
 
-	if (udev_input_init(&ec->input,
-			    &ec->base, ec->udev, param->seat_id) < 0) {
-		weston_log("failed to create input devices\n");
-		goto err_sprite;
-	}
-
 	loop = wl_display_get_event_loop(ec->base.wl_display);
 	ec->drm_source =
 		wl_event_loop_add_fd(loop, ec->drm.fd,
@@ -2843,6 +2843,7 @@ err_udev_monitor:
 	udev_monitor_unref(ec->udev_monitor);
 err_drm_source:
 	wl_event_source_remove(ec->drm_source);
+err_udev_input:
 	udev_input_destroy(&ec->input);
 err_sprite:
 	ec->base.renderer->destroy(&ec->base);
-- 
1.8.3.2



More information about the wayland-devel mailing list