[libvirt] [PATCH] virCapabilitiesInitCaches: Don't leak cache dir

To every virDirOpen we must have VIR_DIR_CLOSE otherwise FD is leaked. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/conf/capabilities.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index d699b0817..a91a72a35 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; } -- 2.13.0

On Mon, May 22, 2017 at 12:08:53PM +0200, Michal Privoznik wrote:
To every virDirOpen we must have VIR_DIR_CLOSE otherwise FD is leaked.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/conf/capabilities.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
participants (2)
-
Michal Privoznik
-
Pavel Hrdina