From: Mingming Cao <cmm@us.ibm.com>
To: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Cc: tytso@mit.edu, linux-ext4@vger.kernel.org
Subject: Re: [RFC/PATCH] ext4: Fix the memory leak and buffer head leak with respect to ext4_ext_path
Date: Thu, 14 Feb 2008 15:21:01 -0800 [thread overview]
Message-ID: <1203031261.3637.46.camel@localhost.localdomain> (raw)
In-Reply-To: <1202985052-15694-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
Added in ext4 patch queue,
Thanks
On Thu, 2008-02-14 at 16:00 +0530, Aneesh Kumar K.V wrote:
> The path variable returned via ext4_ext_find_extent is a kmalloc variable
> and need to be freeded. It also contain refrences to buffer_head which need
> to be dropped.
>
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
> ---
> fs/ext4/extents.c | 6 +++---
> fs/ext4/migrate.c | 5 +++++
> include/linux/ext4_fs_extents.h | 1 +
> 3 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
> index e856f66..995ac16 100644
> --- a/fs/ext4/extents.c
> +++ b/fs/ext4/extents.c
> @@ -349,7 +349,7 @@ static void ext4_ext_show_leaf(struct inode *inode, struct ext4_ext_path *path)
> #define ext4_ext_show_leaf(inode,path)
> #endif
>
> -static void ext4_ext_drop_refs(struct ext4_ext_path *path)
> +void ext4_ext_drop_refs(struct ext4_ext_path *path)
> {
> int depth = path->p_depth;
> int i;
> @@ -2200,10 +2200,10 @@ static int ext4_ext_convert_to_initialized(handle_t *handle,
> newdepth = ext_depth(inode);
> if (newdepth != depth) {
> depth = newdepth;
> - path = ext4_ext_find_extent(inode, iblock, NULL);
> + ext4_ext_drop_refs(path);
> + path = ext4_ext_find_extent(inode, iblock, path);
> if (IS_ERR(path)) {
> err = PTR_ERR(path);
> - path = NULL;
> goto out;
> }
> eh = path[depth].p_hdr;
> diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
> index 8c6c685..5c1e27d 100644
> --- a/fs/ext4/migrate.c
> +++ b/fs/ext4/migrate.c
> @@ -43,6 +43,7 @@ static int finish_range(handle_t *handle, struct inode *inode,
>
> if (IS_ERR(path)) {
> retval = PTR_ERR(path);
> + path = NULL;
> goto err_out;
> }
>
> @@ -74,6 +75,10 @@ static int finish_range(handle_t *handle, struct inode *inode,
> }
> retval = ext4_ext_insert_extent(handle, inode, path, &newext);
> err_out:
> + if (path) {
> + ext4_ext_drop_refs(path);
> + kfree(path);
> + }
> lb->first_pblock = 0;
> return retval;
> }
> diff --git a/include/linux/ext4_fs_extents.h b/include/linux/ext4_fs_extents.h
> index 697da4b..1285c58 100644
> --- a/include/linux/ext4_fs_extents.h
> +++ b/include/linux/ext4_fs_extents.h
> @@ -227,5 +227,6 @@ extern int ext4_ext_search_left(struct inode *, struct ext4_ext_path *,
> ext4_lblk_t *, ext4_fsblk_t *);
> extern int ext4_ext_search_right(struct inode *, struct ext4_ext_path *,
> ext4_lblk_t *, ext4_fsblk_t *);
> +extern void ext4_ext_drop_refs(struct ext4_ext_path *);
> #endif /* _LINUX_EXT4_EXTENTS */
>
prev parent reply other threads:[~2008-02-14 23:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-14 10:30 [RFC/PATCH] ext4: Fix the memory leak and buffer head leak with respect to ext4_ext_path Aneesh Kumar K.V
2008-02-14 10:30 ` [RFC/PATCH] ext4: Request for journal write access early Aneesh Kumar K.V
2008-02-14 18:46 ` Mingming Cao
2008-02-14 23:21 ` Mingming Cao
2008-02-15 20:30 ` Theodore Tso
2008-02-14 18:34 ` [RFC/PATCH] ext4: Fix the memory leak and buffer head leak with respect to ext4_ext_path Mingming Cao
2008-02-14 23:21 ` Mingming Cao [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=1203031261.3637.46.camel@localhost.localdomain \
--to=cmm@us.ibm.com \
--cc=aneesh.kumar@linux.vnet.ibm.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