From ef31de0b4ad4ca808e02691ee8683d70b8771176 Mon Sep 17 00:00:00 2001 From: Peter Fang Date: Tue, 7 May 2024 01:50:00 -0700 Subject: [PATCH] backends/igvm: Fix memory leak Always pair igvm_get_buffer() with igvm_free_buffer() before exiting the loop in supported_platform_compat_mask(). Signed-off-by: Peter Fang --- backends/igvm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backends/igvm.c b/backends/igvm.c index aba5586bc01d..1cfe24ffe6e6 100644 --- a/backends/igvm.c +++ b/backends/igvm.c @@ -722,6 +722,7 @@ static int supported_platform_compat_mask(struct igvm_context *ctx, IgvmVariableHeaderType typ = igvm_get_header_type(ctx->cgs->igvm, HEADER_SECTION_PLATFORM, i); if (typ == IGVM_VHT_SUPPORTED_PLATFORM) { + bool found = false; header_handle = igvm_get_header(ctx->cgs->igvm, HEADER_SECTION_PLATFORM, i); if (header_handle < 0) { @@ -756,10 +757,13 @@ static int supported_platform_compat_mask(struct igvm_context *ctx, platform->highest_vtl, platform->shared_gpa_boundary)) { ctx->compatibility_mask = platform->compatibility_mask; ctx->platform_type = platform->platform_type; - break; + found = true; } } igvm_free_buffer(ctx->cgs->igvm, header_handle); + if (found) { + break; + } } } if (ctx->compatibility_mask == 0) {