From c659792d7bc359ff19706624e26e9aab160a4b56 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sat, 1 Oct 2022 17:52:34 +0200 Subject: render/allocator/drm_dumb: fix error handling In the CREATE_DUMB error code-path, we'd only free() the buffer, however it's already inserted in the alloc->buffers list at this point. Instead, make sure finish_buffer() is safe to call (by populating drm_fd) and call that function. --- render/allocator/drm_dumb.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'render') diff --git a/render/allocator/drm_dumb.c b/render/allocator/drm_dumb.c index 024e5d4f..03d9ff98 100644 --- a/render/allocator/drm_dumb.c +++ b/render/allocator/drm_dumb.c @@ -70,6 +70,8 @@ static struct wlr_drm_dumb_buffer *create_buffer( wlr_buffer_init(&buffer->base, &buffer_impl, width, height); wl_list_insert(&alloc->buffers, &buffer->link); + buffer->drm_fd = alloc->drm_fd; + struct drm_mode_create_dumb create = {0}; create.width = (uint32_t)width; create.height = (uint32_t)height; @@ -77,7 +79,7 @@ static struct wlr_drm_dumb_buffer *create_buffer( if (drmIoctl(alloc->drm_fd, DRM_IOCTL_MODE_CREATE_DUMB, &create) != 0) { wlr_log_errno(WLR_ERROR, "Failed to create DRM dumb buffer"); - goto create_err; + goto create_destroy; } buffer->width = create.width; @@ -87,8 +89,6 @@ static struct wlr_drm_dumb_buffer *create_buffer( buffer->handle = create.handle; buffer->format = format->format; - buffer->drm_fd = alloc->drm_fd; - struct drm_mode_map_dumb map = {0}; map.handle = buffer->handle; @@ -133,7 +133,6 @@ static struct wlr_drm_dumb_buffer *create_buffer( create_destroy: finish_buffer(buffer); -create_err: free(buffer); return NULL; } -- cgit v1.2.3