All of lore.kernel.org
 help / color / mirror / Atom feed
From: zhanchengbin <zhanchengbin1@huawei.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: <linux-ext4@vger.kernel.org>, <liuzhiqiang26@huawei.com>,
	<linfeilong@huawei.com>, <wubo40@huawei.com>
Subject: [PATCH v2 4/6] e2fsprogs: call ext2fs_badblocks_list_free() to free, list in exception branch
Date: Fri, 31 Dec 2021 15:42:40 +0800	[thread overview]
Message-ID: <cbfd9852-bc89-1e83-f101-36fd29a0e70e@huawei.com> (raw)
In-Reply-To: <52a2a39d-617f-2f27-a8a4-34da6103e44c@huawei.com>

In the exception branch,if we donot call ext2fs_badblocks_list_free() to
free bb_list|badblock_list, memory leak will occur.

Signed-off-by: zhanchengbin <zhanchengbin1@huawei.com>
---
  misc/dumpe2fs.c    | 1 +
  resize/resize2fs.c | 4 ++--
  2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
index 3f4fc4ed..ef6d1cb8 100644
--- a/misc/dumpe2fs.c
+++ b/misc/dumpe2fs.c
@@ -338,6 +338,7 @@ static void list_bad_blocks(ext2_filsys fs, int dump)
  	if (retval) {
  		com_err("ext2fs_badblocks_list_iterate_begin", retval,
  			"%s", _("while printing bad block list"));
+		ext2fs_badblocks_list_free(bb_list);
  		return;
  	}
  	if (dump) {
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index b9783e8c..3b9b1ed1 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -1781,11 +1781,11 @@ static errcode_t block_mover(ext2_resize_t rfs)
  					fs->inode_blocks_per_group,
  					&rfs->itable_buf);
  		if (retval)
-			return retval;
+			goto errout;
  	}
  	retval = ext2fs_create_extent_table(&rfs->bmap, 0);
  	if (retval)
-		return retval;
+		goto errout;

  	/*
  	 * The first step is to figure out where all of the blocks
-- 
2.27.0


  parent reply	other threads:[~2021-12-31  7:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-31  7:40 [PATCH v2 0/6] solve memory leak and check whether NULL pointer zhanchengbin
2021-12-31  7:41 ` [PATCH v2 1/6] e2fsck: set s->len=0 if malloc() fails in, alloc_string() zhanchengbin
2021-12-31  7:42 ` [PATCH v2 2/6] lib/ss: check whether argp is null before accessing it, in ss_execute_command() zhanchengbin
2021-12-31  7:42 ` [PATCH v2 3/6] lib/support: check whether inump is null before, accessing it in quota_set_sb_inum() zhanchengbin
2021-12-31  7:42 ` zhanchengbin [this message]
2021-12-31  7:43 ` [PATCH v2 5/6] e2fsck: check whether ldesc is null before accessing, it in end_problem_latch() zhanchengbin
2021-12-31  7:43 ` [PATCH v2 6/6] lib/ext2fs: call ext2fs_free_mem() to free &io->name, in exception branch zhanchengbin
2022-05-12 17:14 ` [PATCH v2 0/6] solve memory leak and check whether NULL pointer Theodore 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=cbfd9852-bc89-1e83-f101-36fd29a0e70e@huawei.com \
    --to=zhanchengbin1@huawei.com \
    --cc=linfeilong@huawei.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=liuzhiqiang26@huawei.com \
    --cc=tytso@mit.edu \
    --cc=wubo40@huawei.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.