aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2023-05-18 11:16:37 +0200
committerSimon Ser <contact@emersion.fr>2023-05-18 11:20:21 +0200
commita0ebc401d0b529ccede2f895566d4ab8f47986e5 (patch)
treebc5eb687b8618e9baf4943038556b7fca0601a61
parent43b25fd34ebeac257942e6fe128f4c5139a84b10 (diff)
linux-dmabuf-v1: fix wlr_drm_format_set leak in feedback_compile()
Fixes: 43b25fd34ebe ("dmabuf: Remove assumption that all mods are in fallback tranche")
-rw-r--r--types/wlr_linux_dmabuf_v1.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/types/wlr_linux_dmabuf_v1.c b/types/wlr_linux_dmabuf_v1.c
index 7e044c60..7145b980 100644
--- a/types/wlr_linux_dmabuf_v1.c
+++ b/types/wlr_linux_dmabuf_v1.c
@@ -509,7 +509,7 @@ static struct wlr_linux_dmabuf_feedback_v1_compiled *feedback_compile(
const struct wlr_linux_dmabuf_feedback_v1_tranche *tranche = &tranches[i];
if (!wlr_drm_format_set_union(&all_formats, &all_formats, &tranche->formats)) {
wlr_log(WLR_ERROR, "Failed to union scanout formats into one tranche");
- return false;
+ goto err_all_formats;
}
}
@@ -534,7 +534,7 @@ static struct wlr_linux_dmabuf_feedback_v1_compiled *feedback_compile(
wlr_log_errno(WLR_ERROR, "mmap failed");
close(rw_fd);
close(ro_fd);
- return NULL;
+ goto err_all_formats;
}
close(rw_fd);
@@ -560,7 +560,7 @@ static struct wlr_linux_dmabuf_feedback_v1_compiled *feedback_compile(
tranches_len * sizeof(struct wlr_linux_dmabuf_feedback_v1_compiled_tranche));
if (compiled == NULL) {
close(ro_fd);
- return NULL;
+ goto err_all_formats;
}
compiled->main_device = feedback->main_device;
@@ -604,11 +604,15 @@ static struct wlr_linux_dmabuf_feedback_v1_compiled *feedback_compile(
compiled_tranche->indices.size = n * sizeof(uint16_t);
}
+ wlr_drm_format_set_finish(&all_formats);
+
return compiled;
error_compiled:
close(compiled->table_fd);
free(compiled);
+err_all_formats:
+ wlr_drm_format_set_finish(&all_formats);
return NULL;
}