Patchwork e2fsprogs: fix freeing bitmap in allocation error path

login
register
mail settings
Submitter Lukas Czerner
Date March 21, 2011, 10:13 a.m.
Message ID <1300702421-4774-1-git-send-email-lczerner@redhat.com>
Download mbox | patch
Permalink /patch/87734/
State Accepted
Headers show

Comments

Lukas Czerner - March 21, 2011, 10:13 a.m.
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.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
---
 lib/ext2fs/gen_bitmap64.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Theodore Ts'o - May 25, 2011, 11:30 p.m.
On Mon, Mar 21, 2011 at 11:13:41AM +0100, Lukas Czerner wrote:
> 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.
> 
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>

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
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
index df095ac..8b9e4c5 100644
--- a/lib/ext2fs/gen_bitmap64.c
+++ b/lib/ext2fs/gen_bitmap64.c
@@ -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;
 	}