frontends/va: Fix leaks when create_video_codec fails

Cc: mesa-stable
Reviewed-by: Benjamin Cheng <benjamin.cheng@amd.com>
(cherry picked from commit 089cd9d88e)

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40752>
This commit is contained in:
David Rosca 2026-03-19 11:03:51 +01:00 committed by Eric Engestrom
parent 9c88f72f8c
commit f1b6e15252
2 changed files with 9 additions and 6 deletions

View file

@ -5294,7 +5294,7 @@
"description": "frontends/va: Fix leaks when create_video_codec fails",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null

View file

@ -430,18 +430,21 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width,
context->surfaces = _mesa_set_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
context->buffers = _mesa_set_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
mtx_lock(&drv->mutex);
*context_id = handle_table_add(drv->htab, context);
mtx_unlock(&drv->mutex);
if (create_decoder) {
mtx_lock(&drv->mutex);
context->decoder = drv->pipe->create_video_codec(drv->pipe, &context->templat);
mtx_unlock(&drv->mutex);
if (!context->decoder)
if (!context->decoder) {
vlVaDestroyContext(ctx, *context_id);
*context_id = VA_INVALID_ID;
return VA_STATUS_ERROR_ALLOCATION_FAILED;
}
}
mtx_lock(&drv->mutex);
*context_id = handle_table_add(drv->htab, context);
mtx_unlock(&drv->mutex);
return VA_STATUS_SUCCESS;
}