From: Michal Privoznik Date: Mon, 22 May 2017 10:07:19 +0000 (+0200) Subject: virCapabilitiesInitCaches: Don't leak cache dir X-Git-Tag: v3.4.0-rc1~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0b60f88791e256cb9b3e6d8bd23f6eb6a87c6192;p=thirdparty%2Flibvirt.git virCapabilitiesInitCaches: Don't leak cache dir To every virDirOpen we must have VIR_DIR_CLOSE otherwise FD is leaked. Signed-off-by: Michal Privoznik Reviewed-by: Pavel Hrdina --- diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index d699b08173..a91a72a35d 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -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; }