]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virCapabilitiesInitCaches: Don't leak cache dir
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 22 May 2017 10:07:19 +0000 (12:07 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 22 May 2017 10:57:30 +0000 (12:57 +0200)
To every virDirOpen we must have VIR_DIR_CLOSE otherwise FD is
leaked.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
src/conf/capabilities.c

index d699b081730f804de24f3ec5703867fe55549bf0..a91a72a35de8afd025023e9959170215827c2657 100644 (file)
@@ -1555,6 +1555,8 @@ virCapabilitiesInitCaches(virCapsPtr caps)
         if (virAsprintf(&path, "%s/cpu/cpu%zd/cache/", SYSFS_SYSTEM_PATH, pos) < 0)
             goto cleanup;
 
+        VIR_DIR_CLOSE(dirp);
+
         rv = virDirOpenIfExists(&dirp, path);
         if (rv < 0)
             goto cleanup;
@@ -1639,7 +1641,7 @@ virCapabilitiesInitCaches(virCapsPtr caps)
  cleanup:
     VIR_FREE(type);
     VIR_FREE(path);
-    virDirClose(&dirp);
+    VIR_DIR_CLOSE(dirp);
     virCapsHostCacheBankFree(bank);
     return ret;
 }