From: "J. Bruce Fields" <bfields@fieldses.org>
To: Rui Xiang <rui.xiang@huawei.com>
Cc: Trond Myklebust <trond.myklebust@primarydata.com>,
linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1/2] nfs/nfsd: return err directly while malloc failing
Date: Fri, 6 Dec 2013 10:36:17 -0500 [thread overview]
Message-ID: <20131206153617.GA9020@fieldses.org> (raw)
In-Reply-To: <1386322217-27436-1-git-send-email-rui.xiang@huawei.com>
On Fri, Dec 06, 2013 at 05:30:16PM +0800, Rui Xiang wrote:
> while nthreads malloc fails, return err value directory
> without kfree.
>
> And the same issue arises in nfs_lookup, so return res
> directly without freeing fh and fattr.
>
> Signed-off-by: Rui Xiang <rui.xiang@huawei.com>
> ---
> fs/nfs/dir.c | 4 ++--
> fs/nfsd/nfsctl.c | 7 ++++---
> 2 files changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index 812154a..2518865 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -1278,7 +1278,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in
>
> res = ERR_PTR(-ENAMETOOLONG);
> if (dentry->d_name.len > NFS_SERVER(dir)->namelen)
> - goto out;
> + return res;
>
> /*
> * If we're doing an exclusive create, optimize away the lookup
> @@ -1287,7 +1287,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in
> if (nfs_is_exclusive_create(dir, flags)) {
> d_instantiate(dentry, NULL);
> res = NULL;
> - goto out;
> + return res;
> }
>
> res = ERR_PTR(-ENOMEM);
> diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
> index 7f55517..3c5e748 100644
> --- a/fs/nfsd/nfsctl.c
> +++ b/fs/nfsd/nfsctl.c
> @@ -491,9 +491,10 @@ static ssize_t write_pool_threads(struct file *file, char *buf, size_t size)
> }
>
> nthreads = kcalloc(npools, sizeof(int), GFP_KERNEL);
> - rv = -ENOMEM;
> - if (nthreads == NULL)
> - goto out_free;
> + if (nthreads == NULL) {
> + mutex_unlock(&nfsd_mutex);
> + return -ENOENT;
> + }
>
> if (size > 0) {
> for (i = 0; i < npools; i++) {
> --
Looks fine. Could you send this last chunk to me as a separate patch?
--b.
> 1.8.2.2
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2013-12-06 15:36 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-06 9:30 [PATCH 1/2] nfs/nfsd: return err directly while malloc failing Rui Xiang
2013-12-06 9:30 ` [PATCH 2/2] nfs: fix return err if inode exiting in nfs_instantiate Rui Xiang
2013-12-06 13:46 ` Trond Myklebust
2013-12-09 10:42 ` Rui Xiang
2013-12-10 16:26 ` Trond Myklebust
2013-12-11 6:09 ` Rui Xiang
2013-12-06 15:36 ` J. Bruce Fields [this message]
2013-12-09 12:33 ` [PATCH 1/2] nfs/nfsd: return err directly while malloc failing Rui Xiang
2013-12-10 16:24 ` Trond Myklebust
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=20131206153617.GA9020@fieldses.org \
--to=bfields@fieldses.org \
--cc=linux-nfs@vger.kernel.org \
--cc=rui.xiang@huawei.com \
--cc=trond.myklebust@primarydata.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).