aboutsummaryrefslogtreecommitdiffstats
path: root/tools/hv/hv_kvp_daemon.c
diff options
context:
space:
mode:
authorTomas Hozza <thozza@redhat.com>2013-05-22 08:54:33 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-03 17:13:09 -0400
commitfca597558e47f936a0e03bab15af726aa3a0fa0e (patch)
treebeadcfb08e0983eb3c391cd3d87a860eadec3243 /tools/hv/hv_kvp_daemon.c
parentf14e600a3bb62905fe9e4e0350048af4ead54ca9 (diff)
tools: hv: Fix file descriptor leaks
Close "fd" file descriptor when is goes out of scope so it does not leak. Signed-off-by: Tomas Hozza <thozza@redhat.com> Acked-by: K. Y. Srinivasan <kys@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'tools/hv/hv_kvp_daemon.c')
-rw-r--r--tools/hv/hv_kvp_daemon.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/hv/hv_kvp_daemon.c b/tools/hv/hv_kvp_daemon.c
index 5b8f28f2aafa..d55ce4040b74 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)
257 257
258 258
259 filep = fopen(fname, "re"); 259 filep = fopen(fname, "re");
260 if (!filep) 260 if (!filep) {
261 close(fd);
261 return 1; 262 return 1;
263 }
262 264
263 record = malloc(alloc_unit * num_blocks); 265 record = malloc(alloc_unit * num_blocks);
264 if (record == NULL) { 266 if (record == NULL) {
265 fclose(filep); 267 fclose(filep);
268 close(fd);
266 return 1; 269 return 1;
267 } 270 }
268 for (;;) { 271 for (;;) {
@@ -286,6 +289,7 @@ static int kvp_file_init(void)
286 num_blocks); 289 num_blocks);
287 if (record == NULL) { 290 if (record == NULL) {
288 fclose(filep); 291 fclose(filep);
292 close(fd);
289 return 1; 293 return 1;
290 } 294 }
291 continue; 295 continue;