fix memory leak and return value 80/15380/3
authorgiyeol.ok <giyeol.ok@samsung.com>
Thu, 27 Jun 2013 01:21:55 +0000 (10:21 +0900)
committerJiyoung Yun <jy910.yun@samsung.com>
Tue, 21 Jan 2014 08:14:25 +0000 (00:14 -0800)
Change-Id: I4db1099fad531a4cc4f83ee8d133f972395871a2
Signed-off-by: giyeol.ok <giyeol.ok@samsung.com>
fsck-msdos/check.c
src/mmc/mmc-handler.c

index 0ef1a0a..bb5fbc2 100644 (file)
@@ -108,6 +108,8 @@ checkfilesys(const char *fname)
        mod |= readfat(dosfs, &boot, boot.ValidFat >= 0 ? boot.ValidFat : 0, &fat);
        if (mod & FSFATAL) {
                printf("Fatal error during readfat()\n");
+               if (fat)
+                       free(fat);
                close(dosfs);
                return 8;
        }
index 6c40be6..dbbcb15 100644 (file)
@@ -767,14 +767,13 @@ int register_mmc_handler(const char *name, const struct mmc_filesystem_ops files
 
        if (!entry->name) {
                _E("Malloc failed");
-               free(entry);
-               return -1;
+               goto free_entry;
        }
 
        entry->fs_ops = malloc(sizeof(struct mmc_filesystem_ops));
        if (!entry->fs_ops) {
                _E("Malloc failed");
-               return -1;
+               goto free_entry_with_name;
        }
 
        entry->fs_ops->init = filesystem_type.init;
@@ -788,6 +787,14 @@ int register_mmc_handler(const char *name, const struct mmc_filesystem_ops files
                entry = get_mmc_fs(tmp, struct mmc_filesystem_info, list);
        }
        return 0;
+
+       free_entry_with_name:
+       free(entry->name);
+
+       free_entry:
+       free(entry);
+
+       return -1;
 }
 
 static void ss_mmc_booting_done(void* data)