From fc0eb6554bc7a40659dcf12e9619481d57da2013 Mon Sep 17 00:00:00 2001 From: SureshGuttula Date: Thu, 11 Feb 2021 23:06:17 +0530 Subject: [PATCH] frontends/va : Fix memory leaks incase of error returns Incase of error returns missed the free calls for config and context. This patch handling in freeing them Signed-off-by: SureshGuttula Reviewed-by: Vinson Lee Part-of: --- src/gallium/frontends/va/config.c | 4 +++- src/gallium/frontends/va/context.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gallium/frontends/va/config.c b/src/gallium/frontends/va/config.c index e658867f6e0..2b37d8cb8d3 100644 --- a/src/gallium/frontends/va/config.c +++ b/src/gallium/frontends/va/config.c @@ -214,8 +214,10 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin return VA_STATUS_ERROR_ALLOCATION_FAILED; if (profile == VAProfileNone) { - if (entrypoint != VAEntrypointVideoProc) + if (entrypoint != VAEntrypointVideoProc) { + FREE(config); return VA_STATUS_ERROR_UNSUPPORTED_ENTRYPOINT; + } config->entrypoint = PIPE_VIDEO_ENTRYPOINT_UNKNOWN; config->profile = PIPE_VIDEO_PROFILE_UNKNOWN; diff --git a/src/gallium/frontends/va/context.c b/src/gallium/frontends/va/context.c index 556e0cb74e7..53077ee45c7 100644 --- a/src/gallium/frontends/va/context.c +++ b/src/gallium/frontends/va/context.c @@ -251,8 +251,10 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width, config->profile, config->entrypoint, PIPE_VIDEO_CAP_MAX_HEIGHT); - if (picture_width > max_supported_width || picture_height > max_supported_height) + if (picture_width > max_supported_width || picture_height > max_supported_height) { + FREE(context); return VA_STATUS_ERROR_RESOLUTION_NOT_SUPPORTED; + } } context->templat.profile = config->profile; context->templat.entrypoint = config->entrypoint;