diff options
author | Stefan Brüns <stefan.bruens@rwth-aachen.de> | 2016-09-06 04:36:56 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2016-09-23 09:02:44 -0400 |
commit | b1edcf0d8045d0b6929ce8d384fb7b350e3fc9ce (patch) | |
tree | 7b88747ce3c00e0b6f555bc0e7a5e268c4471392 /fs | |
parent | de9e831675d72c08c2cc3361a8e9b413ff3facec (diff) |
ext4: Fix memory leak of journal buffer if block is updated multiple times
If the same block is updated multiple times in a row during a single
file system operation, gd_index is decremented to use the same journal
entry again. Avoid loosing the already allocated buffer.
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/ext4_journal.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/ext4/ext4_journal.c b/fs/ext4/ext4_journal.c index cf14049c329..5a25be4c8ac 100644 --- a/fs/ext4/ext4_journal.c +++ b/fs/ext4/ext4_journal.c @@ -190,7 +190,11 @@ int ext4fs_put_metadata(char *metadata_buffer, uint32_t blknr) printf("Invalid input arguments %s\n", __func__); return -EINVAL; } - dirty_block_ptr[gd_index]->buf = zalloc(fs->blksz); + if (dirty_block_ptr[gd_index]->buf) + assert(dirty_block_ptr[gd_index]->blknr == blknr); + else + dirty_block_ptr[gd_index]->buf = zalloc(fs->blksz); + if (!dirty_block_ptr[gd_index]->buf) return -ENOMEM; memcpy(dirty_block_ptr[gd_index]->buf, metadata_buffer, fs->blksz); |