diff mbox

mke2fs: Avoid segmentation fault in ext2fs_alloc_generic_bmap.

Message ID 1304955207-4066-1-git-send-email-tm@tao.ma
State Superseded, archived
Headers show

Commit Message

Tao Ma May 9, 2011, 3:33 p.m. UTC
From: Tao Ma <boyu.mt@taobao.com>

In case of error, ext2fs_alloc_generic_bmap free the memory
in the wrong order. So change it to free description first
and then the bitmap.

Signed-off-by: Tao Ma <boyu.mt@taobao.com>
---
 lib/ext2fs/gen_bitmap64.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Lukas Czerner May 9, 2011, 3:45 p.m. UTC | #1
On Mon, 9 May 2011, Tao Ma wrote:

> From: Tao Ma <boyu.mt@taobao.com>
> 
> In case of error, ext2fs_alloc_generic_bmap free the memory
> in the wrong order. So change it to free description first
> and then the bitmap.
> 
> Signed-off-by: Tao Ma <boyu.mt@taobao.com>
> ---
>  lib/ext2fs/gen_bitmap64.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> 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;
>  	}

I have actually sent the same patch a while ago:

http://www.spinics.net/lists/linux-ext4/msg23763.html

but Ted have not picked up this yet.

-Lukas

>  
> 
--
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
Theodore Ts'o May 9, 2011, 4:09 p.m. UTC | #2
On Mon, May 09, 2011 at 05:45:28PM +0200, Lukas Czerner wrote:
> 
> I have actually sent the same patch a while ago:
> 
> http://www.spinics.net/lists/linux-ext4/msg23763.html
> 
> but Ted have not picked up this yet.

I picked it up just the other day, and it's in the "next" branch of
e2fsprogs.

I thought I had sent an e-mail ack, but I may have forgotten to do so
with this patch; my apologies if that was the case!

						- 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
diff mbox

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;
 	}