virCapabilitiesInitCaches: Don't leak cache dir

To every virDirOpen we must have VIR_DIR_CLOSE otherwise FD is
leaked.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NPavel Hrdina <phrdina@redhat.com>
上级 f25f30af
......@@ -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;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册