提交 fca59755 编写于 作者: T Tomas Hozza 提交者: Greg Kroah-Hartman

tools: hv: Fix file descriptor leaks

Close "fd" file descriptor when is goes out of scope so it does
not leak.
Signed-off-by: NTomas Hozza <thozza@redhat.com>
Acked-by: NK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 f14e600a
......@@ -257,12 +257,15 @@ static int kvp_file_init(void)
filep = fopen(fname, "re");
if (!filep)
if (!filep) {
close(fd);
return 1;
}
record = malloc(alloc_unit * num_blocks);
if (record == NULL) {
fclose(filep);
close(fd);
return 1;
}
for (;;) {
......@@ -286,6 +289,7 @@ static int kvp_file_init(void)
num_blocks);
if (record == NULL) {
fclose(filep);
close(fd);
return 1;
}
continue;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册