tools: hv: Fix file descriptor leaks
authorTomas Hozza <thozza@redhat.com>
Wed, 22 May 2013 12:54:33 +0000 (14:54 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 3 Jun 2013 21:13:09 +0000 (14:13 -0700)
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>
tools/hv/hv_kvp_daemon.c

index 5b8f28f2aafa1874642f0a54fbd7067e0f872577..d55ce4040b74910d1de363cbaf301aba7407e68e 100644 (file)
@@ -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;
This page took 0.024778 seconds and 5 git commands to generate.