linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Theodore Tso <tytso@mit.edu>
To: number9652 <number9652@yahoo.com>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH] libext2fs: fix memory leak in block_iterate
Date: Sat, 18 Jul 2009 10:09:49 -0400	[thread overview]
Message-ID: <20090718140949.GB25546@mit.edu> (raw)
In-Reply-To: <900111.75858.qm@web43503.mail.sp1.yahoo.com>

On Tue, Jul 14, 2009 at 09:45:27AM -0700, number9652 wrote:
> 
> One of the error paths in block_iterate could return before freeing the
> scratch memory.  Here we free that memory before returning.

A cleaner patch is simply to let the code in errout: handle freeing
the memory if necessary.  This is what I've checked into the e2fsprogs
maint branch.  Thanks for reporting it!

					- Ted

commit 9922c53a4df10e660a1b425629a1f4db2b4fc03f
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Sat Jul 18 10:02:41 2009 -0400

    libext2fs: fix memory leak in error path in ext2fs_block_iterate2()
    
    Reported-by: Nic Case <number9652@yahoo.com>
    Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

diff --git a/lib/ext2fs/block.c b/lib/ext2fs/block.c
index de5342d..490116d 100644
--- a/lib/ext2fs/block.c
+++ b/lib/ext2fs/block.c
@@ -488,8 +488,10 @@ errcode_t ext2fs_block_iterate2(ext2_filsys fs,
 abort_exit:
 	if (ret & BLOCK_CHANGED) {
 		retval = ext2fs_write_inode(fs, ino, &inode);
-		if (retval)
-			return retval;
+		if (retval) {
+			ret |= BLOCK_ERROR;
+			ctx.errcode = retval;
+		}
 	}
 errout:
 	if (!block_buf)

      reply	other threads:[~2009-07-18 14:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-14 16:45 [PATCH] libext2fs: fix memory leak in block_iterate number9652
2009-07-18 14:09 ` Theodore Tso [this message]

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=20090718140949.GB25546@mit.edu \
    --to=tytso@mit.edu \
    --cc=linux-ext4@vger.kernel.org \
    --cc=number9652@yahoo.com \
    /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).