From: "J. Bruce Fields" <bfields@fieldses.org>
To: Kinglong Mee <kinglongmee@gmail.com>
Cc: "linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH 2/3] nfsd: Fix a memory leak in nfsd4_list_rec_dir()
Date: Wed, 8 Jul 2015 16:43:44 -0400 [thread overview]
Message-ID: <20150708204344.GD19084@fieldses.org> (raw)
In-Reply-To: <559B35AE.60301@gmail.com>
On Tue, Jul 07, 2015 at 10:13:02AM +0800, Kinglong Mee wrote:
> If lookup_one_len() failed, nfsd should free those memory allocated for fname.
Thanks, applying for 4.3.
--b.
>
> Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
> ---
> fs/nfsd/nfs4recover.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
> index d88ea7b..591bfbd 100644
> --- a/fs/nfsd/nfs4recover.c
> +++ b/fs/nfsd/nfs4recover.c
> @@ -272,6 +272,7 @@ nfsd4_list_rec_dir(recdir_func *f, struct nfsd_net *nn)
> .ctx.actor = nfsd4_build_namelist,
> .names = LIST_HEAD_INIT(ctx.names)
> };
> + struct name_list *entry, *tmp;
> int status;
>
> status = nfs4_save_creds(&original_cred);
> @@ -286,9 +287,8 @@ nfsd4_list_rec_dir(recdir_func *f, struct nfsd_net *nn)
>
> status = iterate_dir(nn->rec_file, &ctx.ctx);
> mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_PARENT);
> - while (!list_empty(&ctx.names)) {
> - struct name_list *entry;
> - entry = list_entry(ctx.names.next, struct name_list, list);
> +
> + list_for_each_entry_safe(entry, tmp, &ctx.names, list) {
> if (!status) {
> struct dentry *dentry;
> dentry = lookup_one_len(entry->name, dir, HEXDIR_LEN-1);
> @@ -304,6 +304,12 @@ nfsd4_list_rec_dir(recdir_func *f, struct nfsd_net *nn)
> }
> mutex_unlock(&d_inode(dir)->i_mutex);
> nfs4_reset_creds(original_cred);
> +
> + list_for_each_entry_safe(entry, tmp, &ctx.names, list) {
> + dprintk("NFSD: %s. Left entry %s\n", __func__, entry->name);
> + list_del(&entry->list);
> + kfree(entry);
> + }
> return status;
> }
>
> --
> 2.4.3
next prev parent reply other threads:[~2015-07-08 20:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-07 2:12 [PATCH 1/3] nfsd: Set lc_size_chg before ops->proc_layoutcommit Kinglong Mee
2015-07-07 2:13 ` [PATCH 2/3] nfsd: Fix a memory leak in nfsd4_list_rec_dir() Kinglong Mee
2015-07-08 20:43 ` J. Bruce Fields [this message]
2015-07-07 2:16 ` [PATCH 3/3] nfsd: Drop BUG_ON and don't reply SECLABEL when exports migrated Kinglong Mee
2015-07-08 20:44 ` J. Bruce Fields
2015-07-08 18:44 ` [PATCH 1/3] nfsd: Set lc_size_chg before ops->proc_layoutcommit J. Bruce Fields
2015-07-09 8:04 ` Christoph Hellwig
2015-07-09 9:28 ` Kinglong Mee
2015-07-09 13:52 ` J. Bruce Fields
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=20150708204344.GD19084@fieldses.org \
--to=bfields@fieldses.org \
--cc=kinglongmee@gmail.com \
--cc=linux-nfs@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.