All of lore.kernel.org
 help / color / mirror / Atom feed
From: Theodore Tso <tytso@mit.edu>
To: Manish Katiyar <mkatiyar@gmail.com>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH] e2fsprogs : Fix memory leak in ext2fs_initialize.
Date: Fri, 11 Jul 2008 14:46:25 -0400	[thread overview]
Message-ID: <20080711184625.GC26656@mit.edu> (raw)
In-Reply-To: <ea11fea30807110332n459593eay3ce43cca67d5c676@mail.gmail.com>

Here's how the patch was applied; please note the style fixes I made
in the code and in the patch comments.

       	       	     	 	  	      - Ted

>From adc4e77d89d9a423c3fbe6457676b020c9ad3a64 Mon Sep 17 00:00:00 2001
From: Manish Katiyar <mkatiyar@gmail.com>
Date: Fri, 11 Jul 2008 14:42:57 -0400
Subject: [PATCH] libext2fs: fix potential memory leak in ext2fs_initialize()

If we fail doing ext2fs_allocate_block_bitmap() or
ext2fs_allocate_inode_bitmap() we directly goto cleanup and don't free
the memory allocated to buf.

Signed-off-by: "Manish Katiyar" <mkatiyar@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 lib/ext2fs/initialize.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
index 011656f..e9bfe49 100644
--- a/lib/ext2fs/initialize.c
+++ b/lib/ext2fs/initialize.c
@@ -105,7 +105,7 @@ errcode_t ext2fs_initialize(const char *name, int flags,
 	int		rsv_gdt;
 	int		csum_flag;
 	int		io_flags;
-	char		*buf;
+	char		*buf = 0;
 	char		c;
 
 	if (!param || !param->s_blocks_count)
@@ -429,6 +429,8 @@ ipg_retry:
 	*ret_fs = fs;
 	return 0;
 cleanup:
+	if (buf)
+		free(buf);
 	ext2fs_free(fs);
 	return retval;
 }
-- 
1.5.6.1.205.ge2c7.dirty


      parent reply	other threads:[~2008-07-11 18:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-11 10:32 [PATCH] e2fsprogs : Fix memory leak in ext2fs_initialize Manish Katiyar
2008-07-11 18:41 ` Theodore Tso
2008-07-11 18:53   ` Manish Katiyar
2008-07-11 18:46 ` 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=20080711184625.GC26656@mit.edu \
    --to=tytso@mit.edu \
    --cc=linux-ext4@vger.kernel.org \
    --cc=mkatiyar@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.