Fix fstab memory leak

When reading the fstab config file fails, fstab memory is not freed.
When fstab structure is no longer needed, only half of it is freed.

Free fstab memory in all cases (error or when it is no longer needed).

Change-Id: Ib0758a5aaa69505285bf64143632986a2dbbdccb
Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
diff --git a/fs_mgr/fs_mgr.c b/fs_mgr/fs_mgr.c
index 85ce397..4f11fbb 100644
--- a/fs_mgr/fs_mgr.c
+++ b/fs_mgr/fs_mgr.c
@@ -222,7 +222,7 @@
     char *line = NULL;
     const char *delim = " \t";
     char *save_ptr, *p;
-    struct fstab *fstab;
+    struct fstab *fstab = NULL;
     struct fstab_rec *recs;
     char *key_loc;
     long long part_length;
@@ -345,7 +345,10 @@
     return fstab;
 
 err:
+    fclose(fstab_file);
     free(line);
+    if (fstab)
+        fs_mgr_free_fstab(fstab);
     return NULL;
 }
 
@@ -361,7 +364,6 @@
         free(fstab->recs[i].fs_options);
         free(fstab->recs[i].key_loc);
         free(fstab->recs[i].label);
-        i++;
     }
 
     /* Free the fstab_recs array created by calloc(3) */