summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Brüns <stefan.bruens@rwth-aachen.de>2016-09-06 05:36:51 +0300
committerDongjin Kim <tobetter@gmail.com>2020-02-10 16:44:41 +0300
commit5f86aefb612ab3bddd2c47e114d5b6ffe575b59f (patch)
treef0f04ebdff173614ff9a22e5fa34803e070f36c8
parentc140328021e3ab94faf6d4f905c9550419e1cc7b (diff)
downloadu-boot-5f86aefb612ab3bddd2c47e114d5b6ffe575b59f.tar.xz
ext4: Fix memory leak in case of failure
temp_ptr should always be freed, even if the function is left via goto fail. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
-rw-r--r--fs/ext4/ext4_write.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c
index 4c255adc55..fd11b6751a 100644
--- a/fs/ext4/ext4_write.c
+++ b/fs/ext4/ext4_write.c
@@ -997,7 +997,6 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
sizeof(struct ext2_inode));
if (ext4fs_put_metadata(temp_ptr, parent_itable_blkno))
goto fail;
- free(temp_ptr);
} else {
/*
* If parent and child fall in same inode table block
@@ -1008,7 +1007,6 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
gd_index--;
if (ext4fs_put_metadata(temp_ptr, itable_blkno))
goto fail;
- free(temp_ptr);
}
ext4fs_update();
ext4fs_deinit();
@@ -1019,6 +1017,7 @@ int ext4fs_write(const char *fname, unsigned char *buffer,
fs->curr_inode_no = 0;
free(inode_buffer);
free(g_parent_inode);
+ free(temp_ptr);
g_parent_inode = NULL;
return 0;
@@ -1026,6 +1025,7 @@ fail:
ext4fs_deinit();
free(inode_buffer);
free(g_parent_inode);
+ free(temp_ptr);
g_parent_inode = NULL;
return -1;