aboutsummaryrefslogtreecommitdiff
path: root/render/allocator
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2022-10-01 17:52:34 +0200
committerAlexander Orzechowski <orzechowski.alexander@gmail.com>2022-10-01 19:45:29 +0000
commitc659792d7bc359ff19706624e26e9aab160a4b56 (patch)
tree1f2ddf1425a7011e3b4021e36d84da0b3d64fe80 /render/allocator
parent3e7ea8715bf6817bee847e3bc5816abf69242fc5 (diff)
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.
Diffstat (limited to 'render/allocator')
-rw-r--r--render/allocator/drm_dumb.c7
1 files changed, 3 insertions, 4 deletions
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;
}