diff options
author | Stefan Brüns <stefan.bruens@rwth-aachen.de> | 2016-09-06 04:36:51 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-09-23 09:02:41 -0400 |
commit | 87a40b6e037ce73cb7c3ac93b2a049d5299b92c8 (patch) | |
tree | 69c0e218a73c5b6d78bb76f0afef985376aaaff3 /fs | |
parent | 0ceef3d3710960347fde6c57f12f3de6fe9cfaaf (diff) | |
download | u-boot-87a40b6e037ce73cb7c3ac93b2a049d5299b92c8.zip u-boot-87a40b6e037ce73cb7c3ac93b2a049d5299b92c8.tar.gz u-boot-87a40b6e037ce73cb7c3ac93b2a049d5299b92c8.tar.bz2 |
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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/ext4_write.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c index 8554793..c55e252 100644 --- a/fs/ext4/ext4_write.c +++ b/fs/ext4/ext4_write.c @@ -974,7 +974,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 @@ -985,7 +984,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(); @@ -996,6 +994,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; @@ -1003,6 +1002,7 @@ fail: ext4fs_deinit(); free(inode_buffer); free(g_parent_inode); + free(temp_ptr); g_parent_inode = NULL; return -1; |