Skip to content
Snippets Groups Projects
Commit b1edcf0d authored by Stefan Brüns's avatar Stefan Brüns Committed by Tom Rini
Browse files

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: default avatarStefan Brüns <stefan.bruens@rwth-aachen.de>
parent de9e8316
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment