All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org, dsterba@suse.cz
Subject: [PATCH] btrfs-progs: convert/ext2: Fix memory leak caused by handled ext2_filsys
Date: Wed, 14 Feb 2018 16:09:56 +0800	[thread overview]
Message-ID: <20180214080956.9953-1-wqu@suse.com> (raw)

Exposed convert-test with D=asan.

Unlike btrfs, ext2fs_close() still leaves its ext2_filsys parameter
filled with allocated pointers.

It needs ext2fs_free() to free those pointers.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 convert/source-ext2.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/convert/source-ext2.c b/convert/source-ext2.c
index e9277213b77a..67e97cf87185 100644
--- a/convert/source-ext2.c
+++ b/convert/source-ext2.c
@@ -95,6 +95,7 @@ static int ext2_open_fs(struct btrfs_convert_context *cctx, const char *name)
 	return 0;
 fail:
 	ext2fs_close(ext2_fs);
+	ext2fs_free(ext2_fs);
 	return -1;
 }
 
@@ -179,6 +180,7 @@ static void ext2_close_fs(struct btrfs_convert_context *cctx)
 		cctx->volume_name = NULL;
 	}
 	ext2fs_close(cctx->fs_data);
+	ext2fs_free(cctx->fs_data);
 }
 
 static u8 ext2_filetype_conversion_table[EXT2_FT_MAX] = {
-- 
2.16.1


             reply	other threads:[~2018-02-14  8:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14  8:09 Qu Wenruo [this message]
2018-02-14 15:37 ` [PATCH] btrfs-progs: convert/ext2: Fix memory leak caused by handled ext2_filsys David Sterba

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=20180214080956.9953-1-wqu@suse.com \
    --to=wqu@suse.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@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 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.