Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp175793rwi; Wed, 19 Oct 2022 19:29:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7nutLvOUiXqA5JBMwyllbOhi2BQM3cyF7f9VgIoSBYlqkoGiIe9OUDHAt4sxm2U8Cfu8PD X-Received: by 2002:a17:903:2286:b0:182:2f05:8abb with SMTP id b6-20020a170903228600b001822f058abbmr11257622plh.14.1666232946542; Wed, 19 Oct 2022 19:29:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666232946; cv=none; d=google.com; s=arc-20160816; b=AC1SfDxQfqhDfMlp19GF5/ZpMPPYH3S9kbENptSFfAUFVtTgtL3lVIUr6wC3HTNgnH ho2w0N/ONNoOm6rC1hmTERo0CJNsyBy3OrEjCMS/fVscxgB3n5f8xWro/JtNREbFVsAO RDLfGA1xJ51XTeJbP8OkoSHVAvrnr5mYKrmIl57aHwxXo77AFdkgwUzHMCJYqZydAaUn W52d3fuYzjY/AMdHjImvT3fnG7k83J3+G6rlB5zFL372Z4/LfrGCPTr0+xNh2chOEbPE AV/Y1K4s+yS3l7TPJKc2GnMK9nGZWEd5hXLYDUn5ODNV72iz5d0zYZAkaVKhqe3JXzsw XIfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=rPAYUTef2ZRPzoY+FFsc3+n9oZjG2jbOTSXHk0zx5sk=; b=JrlJ/2Oi/C50eWGnY7jWmXXX8xQ2RB9jPmZW5BTo+tgwRlDns/poZYOnnNhXHR0OAe 1WZU3aJfjn7/DIeDt7TJmxdyQcnA8WCIL7JbS64+QBKFon9mpKf5mz5RhGxBpDCgn0f1 Es7z98gehOPnItknrej/VWWXo4Jpld54ypBDdOAd/sVubBOrlxLt0q4uzygYronMZky7 bCL1I/YP2lmQiBxh3+38gA9VNx3BFiMziNNmau9iFZRGPEXguNJR6mKJljqBqrX7ACYs 3w83723SOW1jP3Sm66LS/mbyLchGw+WcNTmQAc2uP+ZvDkOyJktsWwxDegsPDITqQfuA zDQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u5-20020a056a00158500b0056618176fd4si20547130pfk.148.2022.10.19.19.28.41; Wed, 19 Oct 2022 19:29:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231192AbiJTCSD (ORCPT + 99 others); Wed, 19 Oct 2022 22:18:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231263AbiJTCSD (ORCPT ); Wed, 19 Oct 2022 22:18:03 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 076C5170DF6 for ; Wed, 19 Oct 2022 19:18:00 -0700 (PDT) Received: from dggpeml500023.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4MtB2y22dtzmVGw; Thu, 20 Oct 2022 10:13:14 +0800 (CST) Received: from localhost.localdomain (10.175.101.6) by dggpeml500023.china.huawei.com (7.185.36.114) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 20 Oct 2022 10:17:35 +0800 From: Zhang Xiaoxu To: , , , , Subject: [PATCH] nfs4: Fix kmemleak when allocate slot failed Date: Thu, 20 Oct 2022 11:20:54 +0800 Message-ID: <20221020032054.3260615-1-zhangxiaoxu5@huawei.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500023.china.huawei.com (7.185.36.114) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,WEIRD_QUOTING autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If one of the slot allocate failed, should cleanup all the other allocated slots, otherwise, the allocated slots will leak: unreferenced object 0xffff8881115aa100 (size 64): comm ""mount.nfs"", pid 679, jiffies 4294744957 (age 115.037s) hex dump (first 32 bytes): 00 cc 19 73 81 88 ff ff 00 a0 5a 11 81 88 ff ff ...s......Z..... 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ backtrace: [<000000007a4c434a>] nfs4_find_or_create_slot+0x8e/0x130 [<000000005472a39c>] nfs4_realloc_slot_table+0x23f/0x270 [<00000000cd8ca0eb>] nfs40_init_client+0x4a/0x90 [<00000000128486db>] nfs4_init_client+0xce/0x270 [<000000008d2cacad>] nfs4_set_client+0x1a2/0x2b0 [<000000000e593b52>] nfs4_create_server+0x300/0x5f0 [<00000000e4425dd2>] nfs4_try_get_tree+0x65/0x110 [<00000000d3a6176f>] vfs_get_tree+0x41/0xf0 [<0000000016b5ad4c>] path_mount+0x9b3/0xdd0 [<00000000494cae71>] __x64_sys_mount+0x190/0x1d0 [<000000005d56bdec>] do_syscall_64+0x35/0x80 [<00000000687c9ae4>] entry_SYSCALL_64_after_hwframe+0x46/0xb0 Fixes: abf79bb341bf ("NFS: Add a slot table to struct nfs_client for NFSv4.0 transport blocking") Signed-off-by: Zhang Xiaoxu --- fs/nfs/nfs4client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c index 7a5162afa5c0..1378e228bc04 100644 --- a/fs/nfs/nfs4client.c +++ b/fs/nfs/nfs4client.c @@ -346,6 +346,7 @@ int nfs40_init_client(struct nfs_client *clp) ret = nfs4_setup_slot_table(tbl, NFS4_MAX_SLOT_TABLE, "NFSv4.0 transport Slot table"); if (ret) { + nfs4_shutdown_slot_table(tbl); kfree(tbl); return ret; } -- 2.31.1