From patchwork Mon Aug 26 07:06:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhen X-Patchwork-Id: 13777272 X-Patchwork-Delegate: kuba@kernel.org Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2042.outbound.protection.outlook.com [40.107.255.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD3F1376E6; Mon, 26 Aug 2024 07:09:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.255.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724656192; cv=fail; b=KTNFd3ApJhMda5welSJ/eCmlUs/8wawUb9/fgJJxzoQGcq2xWJ2rGrtjAyBYDL+dhqPyYWgP0mKSpjz4VxqkNE5kSYIe9QRIdulDytp9ZSZmqzQZGrK9WDvoyk64xs9fAzYvEWaNu4U5fpNqpuVS8plPOieuf6NGH0/irsF99WE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724656192; c=relaxed/simple; bh=ikyBGUT6IPvi58Dwf74zS8Reinc4SC3yiabHLbfJlB8=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=FSDTL47hsigi7hO2xGq0j9TAZJd9BLnhdBAcy3cqEP5E9Tp+fLPcZ9DejDDfK90K+8HDPu7N1NndXj9MSeDZCEvELbLdb9+6wDqzGZKN9euf3nc6P3odkiUwk0PE8byIc16eJsDywRcpErCTSLg2CXiT4UnqotycekKx0pGOjI0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com; spf=pass smtp.mailfrom=vivo.com; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b=T+WPA/CO; arc=fail smtp.client-ip=40.107.255.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=vivo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vivo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=vivo.com header.i=@vivo.com header.b="T+WPA/CO" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=LHu9AaoxF4RJcEXmJgfW36x7NW75Yvj+1lRkHj7ogSnW3NKm6i7raXkTAP1I7izNsY+wPJfItd4F8LV5s/KTo4kRHty41WW2k/ocnPjCcrEP3VcGfV+Kwzgz21rm5wg4i9NQJ9LthyKGwfjATuwcRRymyrJORXRuFQ3qpssRrYAChNAV+9Y8krIBfXjp7RPReCIudfScrR5ugWrQcYb8AgC2jqecmaCiWRiKcMn3kh80U2S+QpZ3TC4l7zihgcbcDZsqnwxygwRHC4JJ3239PuN8PbpBxluXnYSorUX4HnyOBTFkvBR+dQcQmPgzA/+R6uPC+VEfUqPsG4tUdIfJ8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=v8Phkwk+9Ax+xylsb5pcd5+lmHlhcodWaTrzxH4TBQ8=; b=NdciGrv67JIfLSAMZHEzTfx/VhTvCCIxfJJ2RyyJAKorZyUYq7HFiJD05bU7M0ZZ4VCXJQ4q+NV+2upowQ6FVrRJV4DqupNNUogrUldZK8lm7v9qeFUnHn3fmB7g+0np8Bt2U+1KPDrBvY7NjVIbP/LdKS7Ib3mSu6ylcrizabS3Rub/n2sxNz8SU0brD64cV7V45XFaEcb48pOhGaUi7q0pTgo/hQ+jLL8xWPzB/sBJh4rUnf6V4s7yCjoyQd6njXms6i6g6N/9ZqfOzUIwPLaq6YXVPTdlPhNz/92k0JbqdcPNps7LsQI0HfxSOvjIRIDHiMGulBSp8ps8Wanx1A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v8Phkwk+9Ax+xylsb5pcd5+lmHlhcodWaTrzxH4TBQ8=; b=T+WPA/CO/HLKhJFJcpiDquOUv0PC3pLAB6ySZgnMX+1gCN4vuSEz+ZiNr1x7Le1CHxJu1z2YWTbMk7ja5J5znlRruU6iOjFzqgWPrgnT2F+gvLSurPs996O/OXqhPIGvB001PG+Gx40mpfFYpGJEhP9QeB24hJ30ik49N6HlYXJB2lhBAIbOYaq9tYdFk41+HT8nklVYMCWWI7QROusxRGzTvMGQx9StjIyAgC+qo7esJtYeWQOdCFPh5Q5dF2aYNa13opUqp9YcGyfjmnc+DbvGbQNON9BzCVntOmAkNrX5UOaTMsGxq8On722czGSSbGvAtIuN6GzHx65/uIPXvg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from KL1PR0601MB4113.apcprd06.prod.outlook.com (2603:1096:820:31::7) by PUZPR06MB5825.apcprd06.prod.outlook.com (2603:1096:301:ea::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7897.24; Mon, 26 Aug 2024 07:09:44 +0000 Received: from KL1PR0601MB4113.apcprd06.prod.outlook.com ([fe80::7e85:dad0:3f7:78a1]) by KL1PR0601MB4113.apcprd06.prod.outlook.com ([fe80::7e85:dad0:3f7:78a1%4]) with mapi id 15.20.7897.021; Mon, 26 Aug 2024 07:09:43 +0000 From: Yan Zhen To: chuck.lever@oracle.com, jlayton@kernel.org, trondmy@kernel.org, anna@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: neilb@suse.de, okorniev@redhat.com, Dai.Ngo@oracle.com, tom@talpey.com, linux-nfs@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, opensource.kernel@vivo.com, Yan Zhen Subject: [PATCH v1] net: sunrpc: Fix error checking for d_hash_and_lookup() Date: Mon, 26 Aug 2024 15:06:59 +0800 Message-Id: <20240826070659.2287801-1-yanzhen@vivo.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SI2PR01CA0016.apcprd01.prod.exchangelabs.com (2603:1096:4:191::20) To KL1PR0601MB4113.apcprd06.prod.outlook.com (2603:1096:820:31::7) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR0601MB4113:EE_|PUZPR06MB5825:EE_ X-MS-Office365-Filtering-Correlation-Id: 97a7a78e-4a81-4d23-2e96-08dcc59e0fa6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|7416014|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: s41g4bkkszfzOJqHhsEM9YdvbuNjl791fivQKROVJpB2JVXJPUzBbnccKiIiW+AQr2jLUuhWxJ+5J+Mj37/dZQb6b2on+9TVKOFGSGVj/mE15wbW03Gixz9ZziRu4bcIG+rf4DKo9jHS65M2mb2fcMXkDHzVwjAk7xmXvTVauMhMnyS7uDa2P0imOvBgYSUsK+Uf5a77WBlEfeKvbNYf95GKrWosACiExnUIzV8Gq3krN5eq4Tu+sDlwyT00NedOALr0sFCq28c+kyBoepoLCie9hy9o4BETdVG1js0thERPINKnn0zimiEI2ucygWCZVzPBkJsnRMOo/3WkyLsRCEwGp1stSbRhwyC1V9x7PuSaNcvxPyKjHLPbgAt2mILg0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255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:KL1PR0601MB4113.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(7416014)(376014)(52116014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: qOqhVNieRMaWS3GfmMWdHHK+StKQ2yzHF+4MEs54fXjvMJotWhwlOhPpbtGFevlgeqT9Ppg3qEL32SzFR/dcOnjteTCYmJv7z6rlZzLMOqQlKr8acqfDA3hSogOu4dRFa6z5tSQNmPmohSJwUITjFFTEdW8r9AdXU57K8xigNDz5egFrx0Bqj1HJHXpafQSMUCL7X1iWtpP1f/poU+x6lP2McorNTHnASA3UzrB/Kt5RyKqoBnNBxFyUytvo5ZqPAnfEpGsRJXwtcpDBLPTF+xCR5UOSzOvyGAr00ohxKfFwcJDUtW68+YnPGfOWJWH+u6VivUqgwwAvKjR6qd8z8siWjtfzTSMzfYCiE7MAVtmyJ2v+fsOQJQz7UUSAY83dsdvFmahvjZPhmrUB3cQH9VNRi4ZN/Meul/pSq8aCt304bnM5gkzNzstospXo0HKh0gDf3v0jJo/ThY4aHp92clqQQhkHYVXtGsMoUCtnvoIvjYj7rfJe0JLYZdWi/k1/F38H5wskS1pjvx/OQ6jrjE5CKSfgAFNx839XARml+zS4pl7y9Z7z0aO4wKk1IGAcnjkCjSL/vqBWiNqDCm8/NqEWfHOAJO7VtQbENBa07cekox1p+RLgLqCfwq/NtStRSE/quCM9dkfgs/QcaSjaOJIo338H5XW7LnerHKuPiG8DK55GxYgm9TvUfXzdHBkGpNuDJTw0HO6j1ve3bQCp33aBMXiEi53lzl73FLkXc4dDIachSAWlIHZjZL79ZtBkJCWGMmLXps9uOrG+fdb5SVSXRG9las5mUVzopwzxD318wsAdVI9uyJ6iWNWRGalwZI5FIPP091TjWKET1HTWz615I6wluWgYGfZOGKtfnyafVdmqtYYYkfiqRHp9r2Ee6gYffMhXAFafNbYrMtWYOluNOYpQbR9GrBDwL3BbuqkmPvjekA2ND0ehSoh+vkN3wzLMf9DH2UHkTW2aRyJZUusI0m1w4Z6+0TTHWhft4rxZWjo4xkxg1YpSxMq5OcZc6/OMpv1tUy+VU+Py4Oj/ScNsEYk6fxlL0fse6ZvjNKDGh04LN+ppOa7ano0uut8sXxBy/fDlaupzTTSyqIGL49RocIuUwpAfCU7gT0cU9JYowYBlD7TPxkqXgtA7OvVN/bnaJrZG7F69gophllzkbl4UeLqBv6jbZDvjh1cfjnKESHbkqwQfq5qVUNpyOPk2nR0MKia9bTIur3+syolqh7ZfAY9z8WYJRfo9+o9ttZkzuzYhFkiQoQtfoP+PkQGPC+hgE20qu4uh2ymaxa/NjtW4m3+LKUlWhW1AutRXDhb6w+ukvSlIc7fxVQb+SvXDD8Fk4y9U7faIYv2H1cR024oUHm6U9V8wmWNn/lJ/WtpsBKd5SiEKD15wVq5dzlWlhLc7KDWIwJW1vSs1DdSzHW9qBAYPn+WFmu4Tls6DDhvWsDC3JXS4y17+2Xk7wqR96Tn/0y9wta0MnSWeyeT/PK8N7NUqqiGko0TIKrZjhWqt0NIicfRd13oHCMro1xz9+pXKmQJpz+rxuJCueSRHPX2IL1H7EyrM8U+i96hPR3wH4R5siCQ+V0eHWujw7Z4b X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97a7a78e-4a81-4d23-2e96-08dcc59e0fa6 X-MS-Exchange-CrossTenant-AuthSource: KL1PR0601MB4113.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2024 07:09:43.9198 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 4VrYsBDqICxjHFlJDpEQZxv2Fo/jPPjT0Las22YxDMdQW5l333ndrH1tXzKkHDGRRLnabdTC7HgpI4HeupPAYw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PUZPR06MB5825 X-Patchwork-Delegate: kuba@kernel.org The d_hash_and_lookup() function returns either an error pointer or NULL. It might be more appropriate to check error using IS_ERR_OR_NULL(). Signed-off-by: Yan Zhen --- net/sunrpc/rpc_pipe.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c index 910a5d850d04..fd03dd46b1f2 100644 --- a/net/sunrpc/rpc_pipe.c +++ b/net/sunrpc/rpc_pipe.c @@ -1306,7 +1306,7 @@ rpc_gssd_dummy_populate(struct dentry *root, struct rpc_pipe *pipe_data) /* We should never get this far if "gssd" doesn't exist */ gssd_dentry = d_hash_and_lookup(root, &q); - if (!gssd_dentry) + if (IS_ERR_OR_NULL(gssd_dentry)) return ERR_PTR(-ENOENT); ret = rpc_populate(gssd_dentry, gssd_dummy_clnt_dir, 0, 1, NULL); @@ -1318,7 +1318,7 @@ rpc_gssd_dummy_populate(struct dentry *root, struct rpc_pipe *pipe_data) q.name = gssd_dummy_clnt_dir[0].name; q.len = strlen(gssd_dummy_clnt_dir[0].name); clnt_dentry = d_hash_and_lookup(gssd_dentry, &q); - if (!clnt_dentry) { + if (IS_ERR_OR_NULL(clnt_dentry)) { __rpc_depopulate(gssd_dentry, gssd_dummy_clnt_dir, 0, 1); pipe_dentry = ERR_PTR(-ENOENT); goto out;