From patchwork Fri Dec 6 09:30:16 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rui Xiang X-Patchwork-Id: 3294111 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3CB9AC0D4A for ; Fri, 6 Dec 2013 09:31:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 998BF20435 for ; Fri, 6 Dec 2013 09:31:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 35A77201FA for ; Fri, 6 Dec 2013 09:30:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757594Ab3LFJa4 (ORCPT ); Fri, 6 Dec 2013 04:30:56 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:11591 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756772Ab3LFJay (ORCPT ); Fri, 6 Dec 2013 04:30:54 -0500 Received: from 172.24.2.119 (EHLO szxeml205-edg.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id AHJ33809; Fri, 06 Dec 2013 17:30:52 +0800 (CST) Received: from SZXEML420-HUB.china.huawei.com (10.82.67.159) by szxeml205-edg.china.huawei.com (172.24.2.58) with Microsoft SMTP Server (TLS) id 14.3.158.1; Fri, 6 Dec 2013 17:30:49 +0800 Received: from localhost (10.135.72.188) by szxeml420-hub.china.huawei.com (10.82.67.159) with Microsoft SMTP Server id 14.3.158.1; Fri, 6 Dec 2013 17:30:42 +0800 From: Rui Xiang To: Trond Myklebust CC: , Rui Xiang Subject: [PATCH 1/2] nfs/nfsd: return err directly while malloc failing Date: Fri, 6 Dec 2013 17:30:16 +0800 Message-ID: <1386322217-27436-1-git-send-email-rui.xiang@huawei.com> X-Mailer: git-send-email 1.8.1.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [10.135.72.188] X-CFilter-Loop: Reflected Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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++) {