linux-dmabuf-v1: fix wlr_drm_format_set leak in feedback_compile()

Fixes: 43b25fd34e ("dmabuf: Remove assumption that all mods are in fallback tranche")
master
Simon Ser 2 years ago
parent 43b25fd34e
commit a0ebc401d0

@ -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]; const struct wlr_linux_dmabuf_feedback_v1_tranche *tranche = &tranches[i];
if (!wlr_drm_format_set_union(&all_formats, &all_formats, &tranche->formats)) { if (!wlr_drm_format_set_union(&all_formats, &all_formats, &tranche->formats)) {
wlr_log(WLR_ERROR, "Failed to union scanout formats into one tranche"); 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"); wlr_log_errno(WLR_ERROR, "mmap failed");
close(rw_fd); close(rw_fd);
close(ro_fd); close(ro_fd);
return NULL; goto err_all_formats;
} }
close(rw_fd); 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)); tranches_len * sizeof(struct wlr_linux_dmabuf_feedback_v1_compiled_tranche));
if (compiled == NULL) { if (compiled == NULL) {
close(ro_fd); close(ro_fd);
return NULL; goto err_all_formats;
} }
compiled->main_device = feedback->main_device; 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); compiled_tranche->indices.size = n * sizeof(uint16_t);
} }
wlr_drm_format_set_finish(&all_formats);
return compiled; return compiled;
error_compiled: error_compiled:
close(compiled->table_fd); close(compiled->table_fd);
free(compiled); free(compiled);
err_all_formats:
wlr_drm_format_set_finish(&all_formats);
return NULL; return NULL;
} }

Loading…
Cancel
Save