Skip to contentSkip to conversation

e2fsprogs: fix freeing bitmap in allocation error path

PATCH In review Lukas Czerner 2 participants 2 messages Mar 21, 2011 – May 25, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 e2fsprogs: fix freeing bitmap in allocation error path

In ext2fs_alloc_generic_bmap() error path, when new bitmap allocation fails ext2fs_generic_bitmap should be freed, however in current state it first frees ext2fs_generic_bitmap and then ext2fs_generic_bitmap->description which is wrong. This commit fix the free ordering.

---
 lib/ext2fs/gen_bitmap64.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
lib/ext2fs/gen_bitmap64.c +1 -1
index df095ac..8b9e4c5 100644
@@ -129,8 +129,8 @@ errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
 
 	retval = bitmap->bitmap_ops->new_bmap(fs, bitmap);
 	if (retval) {
-		ext2fs_free_mem(&bitmap);
 		ext2fs_free_mem(&bitmap->description);
+		ext2fs_free_mem(&bitmap);
 		return retval;
 	}
 
Signature · 1 line
1.7.4
#1 lore raw
Quoted 7 lines · Lukas Czerner

In ext2fs_alloc_generic_bmap() error path, when new bitmap allocation fails ext2fs_generic_bitmap should be freed, however in current state it first frees ext2fs_generic_bitmap and then ext2fs_generic_bitmap->description which is wrong. This commit fix the free ordering.

This was actually pulled into e2fsprogs a while back, but it looks like I forgot to send an e-mail ack (or mark it as accepted in patchwork). So I'm fixing that oversight now.

- Ted