linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tao Ma <tm@tao.ma>
To: linux-ext4@vger.kernel.org
Subject: [PATCH] mke2fs: Avoid segmentation fault in ext2fs_alloc_generic_bmap.
Date: Mon,  9 May 2011 23:33:27 +0800	[thread overview]
Message-ID: <1304955207-4066-1-git-send-email-tm@tao.ma> (raw)

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;
 	}
 
-- 
1.6.3.GIT


             reply	other threads:[~2011-05-09 15:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-09 15:33 Tao Ma [this message]
2011-05-09 15:45 ` [PATCH] mke2fs: Avoid segmentation fault in ext2fs_alloc_generic_bmap Lukas Czerner
2011-05-09 16:09   ` Ted Ts'o

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1304955207-4066-1-git-send-email-tm@tao.ma \
    --to=tm@tao.ma \
    --cc=linux-ext4@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).