From: "Manish Katiyar" <mkatiyar@gmail.com>
To: "Theodore Tso" <tytso@mit.edu>, linux-ext4@vger.kernel.org
Cc: mkatiyar@gmail.com
Subject: [PATCH] libext2fs : Fix memory leak in ext2fs_initialize().
Date: Sat, 23 Aug 2008 17:11:07 +0530 [thread overview]
Message-ID: <ea11fea30808230441h680100d6k1e4524710e6d2d4c@mail.gmail.com> (raw)
Below patch ensures that cleanup is done properly in ext2fs_initialize
from all return paths in case of errors.
Signed-off-by: "Manish Katiyar" <mkatiyar@gmail.com>
---
lib/ext2fs/initialize.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
index 5ed4c06..aa4f424 100644
--- a/lib/ext2fs/initialize.c
+++ b/lib/ext2fs/initialize.c
@@ -254,8 +254,10 @@ retry:
super->s_frags_per_group = super->s_blocks_per_group *
frags_per_block;
goto retry;
- } else
- return EXT2_ET_TOO_MANY_INODES;
+ } else {
+ retval = EXT2_ET_TOO_MANY_INODES;
+ goto cleanup;
+ }
}
if (ipg > (unsigned) EXT2_MAX_INODES_PER_GROUP(super))
@@ -321,8 +323,10 @@ ipg_retry:
fs->desc_blocks + super->s_reserved_gdt_blocks);
/* This can only happen if the user requested too many inodes */
- if (overhead > super->s_blocks_per_group)
- return EXT2_ET_TOO_MANY_INODES;
+ if (overhead > super->s_blocks_per_group) {
+ retval = EXT2_ET_TOO_MANY_INODES;
+ goto cleanup;
+ }
/*
* See if the last group is big enough to support the
@@ -336,8 +340,10 @@ ipg_retry:
overhead += 1 + fs->desc_blocks + super->s_reserved_gdt_blocks;
rem = ((super->s_blocks_count - super->s_first_data_block) %
super->s_blocks_per_group);
- if ((fs->group_desc_count == 1) && rem && (rem < overhead))
- return EXT2_ET_TOOSMALL;
+ if ((fs->group_desc_count == 1) && rem && (rem < overhead)) {
+ retval = EXT2_ET_TOOSMALL;
+ goto cleanup;
+ }
if (rem && (rem < overhead+50)) {
super->s_blocks_count -= rem;
goto retry;
--
1.5.4.3
Thanks -
Manish
next reply other threads:[~2008-08-23 11:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-23 11:41 Manish Katiyar [this message]
2008-08-23 11:56 ` [PATCH] libext2fs : Fix memory leak in ext2fs_initialize() Theodore Tso
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=ea11fea30808230441h680100d6k1e4524710e6d2d4c@mail.gmail.com \
--to=mkatiyar@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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