close file pointer before exiting function
authorLuka Perkov <luka@openwrt.org>
Tue, 9 Jul 2013 23:50:48 +0000 (01:50 +0200)
committerJohn Crispin <blogic@openwrt.org>
Sun, 27 Oct 2013 15:01:09 +0000 (16:01 +0100)
Signed-off-by: Luka Perkov <luka@openwrt.org>
block.c
mount_root.c

diff --git a/block.c b/block.c
index c9285d642ad8346bbb10dede5c9df2af99828ded..2289b779a7a485642789cfc303091ee19a0f4b7a 100644 (file)
--- a/block.c
+++ b/block.c
@@ -545,8 +545,10 @@ static char* find_mount_point(char *block)
                        char *p = &line[len + 1];
                        char *t = strstr(p, " ");
 
-                       if (!t)
+                       if (!t) {
+                               fclose(fp);
                                return NULL;
+                       }
                        *t = '\0';
                        point = p;
                        break;
index ede5718f7bc082e3bcb6faa29c5653ccc18bd63c..8868e40c68203612f18e0a8e4da27f41d3ff8713 100644 (file)
@@ -109,12 +109,16 @@ static char* find_mount(char *mp)
        while (fgets(line, sizeof(line), fp)) {
                char *s, *t = strstr(line, " ");
 
-               if (!t)
+               if (!t) {
+                       fclose(fp);
                        return NULL;
+               }
                t++;
                s = strstr(t, " ");
-               if (!s)
+               if (!s) {
+                       fclose(fp);
                        return NULL;
+               }
                *s = '\0';
 
                if (!strcmp(t, mp)) {
@@ -143,13 +147,16 @@ static char* find_mount_point(char *block, char *fs)
                        char *p = &line[len + 1];
                        char *t = strstr(p, " ");
 
-                       if (!t)
+                       if (!t) {
+                               fclose(fp);
                                return NULL;
+                       }
 
                        *t = '\0';
                        t++;
 
                        if (fs && strncmp(t, fs, strlen(fs))) {
+                               fclose(fp);
                                ERROR("block is mounted with wrong fs\n");
                                return NULL;
                        }