[PATCH 1/1] capabilities: reduce scope in virCapabilitiesInitCaches()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <shaleen.bathla@xxxxxxxxxx>
---
 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 34770fc4165f..9144ced4984f 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;
-- 
2.31.1




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux