From 2f7e11aaa38d850dd1934d9b0492e35af4047ed7 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Wed, 11 Jun 2025 13:52:46 +0200 Subject: [PATCH] virt-aa-helper: Decrease scope of @mem_path in get_files() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The @mem_path variable inside of get_files() is used only within a single block. Move its declaration inside it. And also utilize automatic memory freeing. Signed-off-by: Michal Privoznik Reviewed-by: Ján Tomko --- src/security/virt-aa-helper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 2fac65f108..64cada3b3b 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -866,7 +866,6 @@ get_files(vahControl * ctl) int rc = -1; size_t i; char *uuid; - char *mem_path = NULL; char uuidstr[VIR_UUID_STRING_BUFLEN]; bool needsVfio = false, needsvhost = false, needsgl = false; @@ -1210,6 +1209,8 @@ get_files(vahControl * ctl) "rw") != 0) goto cleanup; } else { + g_autofree char *mem_path = NULL; + switch (shmem->model) { case VIR_DOMAIN_SHMEM_MODEL_IVSHMEM_PLAIN: /* until exposed, recreate qemuBuildShmemBackendMemProps */ @@ -1361,7 +1362,6 @@ get_files(vahControl * ctl) ctl->files = virBufferContentAndReset(&buf); cleanup: - VIR_FREE(mem_path); VIR_FREE(uuid); return rc; } -- 2.47.3