frontends/va: Fix memory leak of decrypt_key

pipe_picture_desc.decrypt_key was alloced in function
handleVAProtectedSliceDataBufferType(), but nowhere to
free it. Now, it will be freed as the vlVaContext is
destroyed.

Fixes: deb7dc82f6 ("frontends/va: handle protected slice data buffer")
Signed-off-by: Feng Jiang <jiangfeng@kylinos.cn>
Reviewed-by: Boyuan Zhang <Boyuan.Zhang@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23202>
(cherry picked from commit 9790350e9d)
This commit is contained in:
Feng Jiang 2023-05-24 15:33:07 +08:00 committed by Eric Engestrom
parent b517255ec8
commit a58e2753f6
3 changed files with 8 additions and 2 deletions

View file

@ -1903,7 +1903,7 @@
"description": "frontends/va: Fix memory leak of decrypt_key",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "deb7dc82f626e92525d01829d88f0ac348de03b8"
},

View file

@ -411,6 +411,7 @@ vlVaDestroyContext(VADriverContextP ctx, VAContextID context_id)
vl_deint_filter_cleanup(context->deint);
FREE(context->deint);
}
FREE(context->desc.base.decrypt_key);
FREE(context);
handle_table_remove(drv->htab, context_id);
mtx_unlock(&drv->mutex);

View file

@ -323,10 +323,15 @@ static void
handleVAProtectedSliceDataBufferType(vlVaContext *context, vlVaBuffer *buf)
{
uint8_t* encrypted_data = (uint8_t*) buf->data;
uint8_t* drm_key;
unsigned int drm_key_size = buf->size;
context->desc.base.decrypt_key = CALLOC(1, drm_key_size);
drm_key = REALLOC(context->desc.base.decrypt_key,
context->desc.base.key_size, drm_key_size);
if (!drm_key)
return;
context->desc.base.decrypt_key = drm_key;
memcpy(context->desc.base.decrypt_key, encrypted_data, drm_key_size);
context->desc.base.key_size = drm_key_size;
context->desc.base.protected_playback = true;