[PATCH 4/4] tools: hv: Fix file descriptor leaks
Tomas Hozza
thozza at redhat.com
Tue May 21 13:36:55 UTC 2013
Close "fd" file descriptor when is goes out of scope so it does
not leak.
Signed-off-by: Tomas Hozza <thozza at redhat.com>
---
tools/hv/hv_kvp_daemon.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index 468ca16..3dbc2eb 100644
--- a/tools/hv/hv_kvp_daemon.c
+++ b/tools/hv/hv_kvp_daemon.c
@@ -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;
--
1.8.1.4
More information about the devel
mailing list