From patchwork Mon Aug 26 11:25:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhen X-Patchwork-Id: 13777678 X-Patchwork-Delegate: kuba@kernel.org Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2071.outbound.protection.outlook.com [40.107.117.71]) (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 ADC19143C7D; Mon, 26 Aug 2024 11:28:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.117.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724671710; cv=fail; b=CFNCDVQbcSEcQcMUIBgJgeh1ppLkAFykAErJvF16OzC2vtF8i9u/F2vQ7PkbOb0RySYcbtaxye1WMxxKgEO8xtrzem5Fcc+2TLv4IA9zjyHxKttrvKOJVwQBi0Om4xTCFfex9YEFsb0XbmF0wtlhHY6S6T2WltB+NBmSIZlgp68= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724671710; c=relaxed/simple; bh=gKzsa6qzZiHgZu80ug8E4wtiQFcSxFQayHOiWoMiz5I=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=iWGs5YvCvssTTbGcIEzcKof5dDycbboMux5q9znBUWGcNcz5nAdG1um3jkBe5kWvmcESgfCbPE7Os9ouF+d4hNRzxHr1cIOHL2tC4nyXqUIF0ZLnMKGVRbFW2cQgzWNDmsvG6jytHJsqcOrkG65ixkzA4YKbQiKLzKNU2bK2pVA= 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=X9gmI8HY; arc=fail smtp.client-ip=40.107.117.71 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="X9gmI8HY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KP+hnXXAWrojkf1j2j+mjxEi7iohEOMsfR+95D9dXbVoE4SR+5FGSrbrcA9DclGCWQ3UlclHIPh84ktcr+/5lB3iNGAtw7M+crQ6G45zy/rnbzg4tdQQUfPJ/of+RqGg7YUp9JxyiYf/DEMAYCJHk/Agv1FqmGmQipbz0rZxQZVNW7eI17zxsSZQ69KLrJ0NHtvOO69v3nJY1nYP7l36jou6+OJnCz1T9PeeaWi/Xp+bBE/4SCPx2wcrKnfbwvY749ptqTLVz3J/Ec5evEffbBZdZinJTPC+C61rrhy5oFSTXaFlyZms+HaJvOLPSbV9llZWMOOyMRcdrp0WG+vQLw== 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=QipNcnJjIK6H2CVDD9TR4jc9Vi9tcfZU1v+HhT39eYU=; b=Uj7j0NzPJ9DpUhx37p9E5TWpVefcKPF6MQWbq6CCMDWjohBYxNLzAy769pQlQE3IwzOiFHpduBHCIQKSBdvwObrZyZrnouH/6YeO1OFnyfqSKfwH+ZXu8YijyuQK0mtVWkJjXG9DtREcWQUEG2Oj/V/BYZ6ZC65ts9YA5gDucsFoxzBdeSYTqNDyiJuTGUytBPLTlPgZQQPsz+UJv3aN7CRihvOtQTiQTtSjW7HqL1ZUl+hpR+cvpohOcQ4au4qkJ40ZcPc3r2PSRMXoXMX84oZB2pf3kME942fsfZwPK3HN0klt/pKQ3dwVkG3UCHK8aq/25F92oxDw0JtAqtP7EA== 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=QipNcnJjIK6H2CVDD9TR4jc9Vi9tcfZU1v+HhT39eYU=; b=X9gmI8HYg89Uqr/mwDFrEFpKt6VK3KEEakfIAp+Xj6tHahONsZYfEWXBcC9XL11D2q+VgEdUAEdm7JUToJaIKltgitxaU2mCmh5BE8IHSeO0xJfepgFqTOjBreXTNoTIMeOX9RmfW7LOQRLZpOV9iNqCWBwbWRBLTGQfX6Py7rOKxcr0r8hOKy3DsiqqwKwGhnNQNb+rqNyabjv539FQ8hk0WP1yiqlmT1Vd3/VCk2XFp6+DQTvt1q+k7nntku3CCuVC4GYXDJU0zD6pW5nLAtl348aKtkbJsu/VJUIvQ9UwGfztBBgz2G79LONCnm3fr5RGJFKMGneEHzsrGxJ0uw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SI2PR06MB4122.apcprd06.prod.outlook.com (2603:1096:4:fc::8) by SEYPR06MB7041.apcprd06.prod.outlook.com (2603:1096:101:1d6::5) 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 11:28:23 +0000 Received: from SI2PR06MB4122.apcprd06.prod.outlook.com ([fe80::b711:7858:9caf:bd78]) by SI2PR06MB4122.apcprd06.prod.outlook.com ([fe80::b711:7858:9caf:bd78%5]) with mapi id 15.20.7897.021; Mon, 26 Aug 2024 11:28:23 +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 v2] sunrpc: Fix error checking for d_hash_and_lookup() Date: Mon, 26 Aug 2024 19:25:09 +0800 Message-Id: <20240826112509.2368945-1-yanzhen@vivo.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: TYWP286CA0019.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:262::6) To SI2PR06MB4122.apcprd06.prod.outlook.com (2603:1096:4:fc::8) 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: SI2PR06MB4122:EE_|SEYPR06MB7041:EE_ X-MS-Office365-Filtering-Correlation-Id: f477d8a3-257b-4f25-aa91-08dcc5c231d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|1800799024|52116014|376014|7416014|38350700014; X-Microsoft-Antispam-Message-Info: meecYWD/h1Z6j1gXdlu2JDoNmTA+NOYb8WijGXiSfpowuJUC4bO2oh/KQudhzjYNLvORVF2h9imJze3BfkEHWoGKOEsgByL07+lq/c1MzVkHgJ6cz54jjAkrjm9+P/h5RmVDOIEtC1nqKiQo1aTFL7gKWu0oo/atELHG/p6WCEOoxD0kCvPnKTXX8OW+9fwpR2S11SKf39WrOqs2HkWCfE4VYyFZzI5ObLe3MWtG/kn5wVeaOcRl347HV36N4ArljD2b05Zyy4sDl4yR0ZftI6uND9qpEfMb9QciH5JlEANJDkDbm293qHxPGCOezHHHHFHdMPZFI4wshw8wdxgsv7zaPNqav7EiGAD66IjVczgYIl3tsxckT9rU7lP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RY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SI2PR06MB4122.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(1800799024)(52116014)(376014)(7416014)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 4nuWE8vzaM3mLymvRr8vYEsxjo6gVCJnJeZfGSVga1WIonmzJWDkoBM4bYRYWikl3P+PRwAgSZq83Sm3TFq/9ydnHWRGAWvk6c4QaGe4CEp86+zS8jfWw7Gu2g6CoFYH3MSTSNXzzuP16vuN5E8szLitfZJBR4y3WRlYCtzQabmYT4t6wyfVIH++33EWDkXoymejmdPNn3b0fX89MqvjhB5lGU67SDLQHOi1CPONs6SCfVFi9mxBekfM68ATnwR6pp7jH/5BZNnIEdCdggFILOET+VsxURuGFcMkt3aZdN+cNKtcpY6+TUiaSDFswEdKJQBbEKN5XFE/OTO2b1Whm3bK2aoTtw1NFvk0frxoDCU8SRIr9zfgaasZxi3SENwjCOpTZp+sauJOjVF3g0h6N/GpxZ1BcqR7rD03xWRwwAV2XSsDRp7yQBSAreoOOAen4hD7gMnMHKOQ+0lcwe4f1hkStEKCggSspzRCYoQ5+SKBn82sKnOTIK7USUYGg4Bk7/Dw4I5Y5+1JloY8TdIel+dHjfRUfF86EMgLmhJjcvOiRC3TI2nI6hFLCHS0kdmYQnGFtG9A168FgeP4qoGexyQy5IKBN3yDov7xpfkpt6rdoNys43sAmiaj5zQd7wWNMhc4gLjaQATWypG7Ef009bkczArwIxDvyV5++t43EyWV0ELn+lM1fg9P2+iZeSvGzqXofJJv9dmHCkhltYy7aZESNu0o+rj+JfiMgPJJC7uz9/pJaA6Vzgvy+sUWzLFoJO4ZBKWmbRwOhTTQgNzmtjAEbam7BavBY3ZNs8ytyIZRcVenFkW80PUTax/4hHN9PCzuiBB/+GhvZoOS9A1syzJZSdp8UEaDjGDrK0zTW5EZ9SxqAMvyhTtS+MtGLZgP8et5WBgy1cAUEfKf7CbFFkRhI6BIEyJJgtReZskAvAB6jmVu60gjPSph/A0VrQUdV2y+OSRIk116K4Mw73/hCRvC1kD/PoEZJfYG0Sbz3KYnO9Q5URKHGLtzdbc4u5lub42opiUmwOna2mQ433YfneeH0USP4tTnOLbPnTM1cZb1XaaCwy9hxeR0Hyp8Yqa0JInwWHAvGtWX8HbKy+HvjnZE2ScqTY3pPTk6hQdzgIaEKS8NKrNEbp9rIJ+jPvEzefIomEogANBADoCoztn6MqSmsS54BWafm4PckaM3wXj50tyCpT9e7orxc6EQrHQpQ4DiGbGFiV2BdvnViAD4qJ4vbym1LkdG5fJ6+vvM/i9VYm/SFuM1d/0wIOKhp2mvGnaj+5iFGkv4W85JlpeX1qCgHczhIDm7tcqRopxF0I2fAVUOoCUjl12OyveHZagr99R59Gl5zYUKPj9Y+Zj6K8fqg24Pzx0w+6ahbX+1qn7EQ4qGeGZp2WxetbChczvEAum9Mcer+m6m4cwU2bfGa9TvOAGenKAsdZsIxi7hwM6/rGPwjsA6eZEQoCY0p2sjhV0FyxkGuvn61e/UXSYmxtIhxPoQaMAL3PsxEkdgCEhMcT9iEw/qedjhqEXyfaJBYEuNBme6D4ASyjWieIG3jtC0BkZVHxXkvFsX03LxibyhB06xQeF8Z/Wk2oQyhZzR X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f477d8a3-257b-4f25-aa91-08dcc5c231d6 X-MS-Exchange-CrossTenant-AuthSource: SI2PR06MB4122.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2024 11:28:23.2073 (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: jxjZTj5IU4NO1IDRUD8wwTFA0+d/uLw0+FUap+GTmR9OWJJs1ieZMo1ZDL+0wUgV3UPGz6RkrXQO6f9rd2T17A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEYPR06MB7041 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(). Fixes: b7ade38165ca ("sunrpc: fixed rollback in rpc_gssd_dummy_populate()") Signed-off-by: Yan Zhen --- Changes in v2: - Providing a "fixes" tag blaming the commit. 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;