From 9a3bccf6956aa8cd6c878e32e0ac70114fada30f Mon Sep 17 00:00:00 2001 From: Shaleen Bathla Date: Mon, 20 Mar 2023 16:09:56 +0530 Subject: [PATCH] capabilities: reduce scope in virCapabilitiesInitCaches() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit over-writing a variable in inner while-loop without freeing previous memory leaks it over time. To fix this, we can just change scope of bank variable to the inner loop. Signed-off-by: Shaleen Bathla Reviewed-by: Ján Tomko Fixes: 5c84485439ee63f40002c04914e111395c598db0 Signed-off-by: Ján Tomko --- src/conf/capabilities.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index 34770fc416..9144ced498 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -2178,7 +2178,6 @@ virCapabilitiesInitCaches(virCaps *caps) int rv = -1; g_autoptr(DIR) dirp = NULL; g_autofree char *path = g_strdup_printf("%s/cpu/cpu%zd/cache/", SYSFS_SYSTEM_PATH, pos); - g_autoptr(virCapsHostCacheBank) bank = NULL; rv = virDirOpenIfExists(&dirp, path); if (rv < 0) @@ -2189,6 +2188,7 @@ virCapabilitiesInitCaches(virCaps *caps) while ((rv = virDirRead(dirp, &ent, path)) > 0) { g_autofree char *type = NULL; + g_autoptr(virCapsHostCacheBank) bank = NULL; int kernel_type; unsigned int level; int ret;