From patchwork Mon Aug 26 09:08:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yan Zhen X-Patchwork-Id: 13777460 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2071.outbound.protection.outlook.com [40.107.215.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 B84FB84A4D for ; Mon, 26 Aug 2024 09:09:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.215.71 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724663365; cv=fail; b=inUmq5eL8o2+ndRBgOU5tw1CypOSpfXploIkpSe3Vqsm9cZjaNoY3KFeQyYnSC6pYHg5lfS1loYe0883cV/2OMIYjSKcfhzGiO5uHGNhTU9YhOWFyxSC67nv+sTuc6yErpN2XtD9ZqODP47w45m4BDYAqQbygd5tddGtY1uF2B0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724663365; c=relaxed/simple; bh=rRIrhcDcCmtiOOA47XwotRav+M01kz+dJqF/+1lfYfY=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=POVCQhtUsWHIIWFOFf376ZNv19Y5WiduCQRKcgF2OatA5vk86Wp8TiXo0c5wtjA+gi8KokmTY91BJejp1RORhLLj7fyNyj0dCeJGD81WLONCqKFSTYiBxd0DFiPG3DQ5Qgrm6J2z2DLdwg7pICrdgODtItRwRNI1brKATpTNsxM= 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=XA5UqHD+; arc=fail smtp.client-ip=40.107.215.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="XA5UqHD+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RgcunT00BOhgYsogAOHGwrTrtF10hSAHOZn0FpZ99d9IMMqjX2wjs7xDMniAsEiQBrtKeQh1T6D9ROmPNLby2hgf71zrjrXJrwz5Mkd2p55RNj7LpopD427X+4+Hz8jx7EHOXtxeoc6mmV4RaGJDSZbjPtRjcljqmwIclXVGdGWhV+xo8+5VI9bArsixSA63b0dRlam2jQJvotxsdIDRJubs6gG2eG5WmSo55PcQ7/RoD5xtZ3yopsxQtSt2tqoiRzBgOv+9Z4yfPT5W3B2QbJjN+KI4YIk9+lAdI+baTXm9shD3B/JLiMNpqdIpPx/KSGtl7QJEfR/1QjuoJvwiPw== 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=NBQLtu+umr0EyUPvH9hSR6BhpufnryJIVhA/s8m7zrQ=; b=udp/sWKctDSwCr/ja8CWTXLAJA8zNTJUIB8T/Gg6LWUZCp3a5y9Zzb23pW6Pl1EAoiO4/sdCY8v7CTVATx2v6JE3v7W0xYdwPwCa0/xpQ1raxcgF/B8tfJYRxZltJBi379SCGsTKbLqnfj0y6mptHioTMC2V2agbctkahhBqGwzdgmRQxeN0pJ3Qs+swmzu0ZwhpF70CIAdh+LRkwBU8i7ryJxwtncIs4BCHim5h3yvcle5RJ8rSOzCxrbIAWqRepsjVrtVFfld1oVFN/rU6ee+ki2bX2gDAPmIsP1RVcDIKg4xjFalHRfwrV7CUyonodeW9a+2ON4IdJ0/zPG38jg== 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=NBQLtu+umr0EyUPvH9hSR6BhpufnryJIVhA/s8m7zrQ=; b=XA5UqHD+5wRHILpH9i8zVsMsUFBFwyIdAhOLDxrLydcnyzDGcbJPteLmH4Y2gTsCaN68QMo9S7YZeV3CoPmcysyQxDuk2Ha/fsl1uWIAfsugw0cHnaGRoZd1v90Ymw+pedilTjzNjAdYU7z9NNq88Klxp1UVGU1b66VhzbFc8KmIUKB1cNeF5XWisIxZjcgLbwbq+gw4dn4fRkfWI9uG9M2OmoA5ac9SfA2JVToVP7SeHefBcuf2EsIEwyuPLYw9MNeUQDGKbgxHBhvMxxF6A3v3gyE/Gi5TYX0+/MS7nzO+CF2FQFD5JgEKQKkb3Ekw4ZmkugYvAbPfTzw+Ml6+SA== 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 SEZPR06MB5763.apcprd06.prod.outlook.com (2603:1096:101:ab::9) 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 09:09:17 +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 09:09:17 +0000 From: Yan Zhen To: viro@zeniv.linux.org.uk, brauner@kernel.org Cc: jack@suse.cz, linux-fsdevel@vger.kernel.org, opensource.kernel@vivo.com, Yan Zhen Subject: [PATCH v1] fs: proc: Fix error checking for d_hash_and_lookup() Date: Mon, 26 Aug 2024 17:08:02 +0800 Message-Id: <20240826090802.2358591-1-yanzhen@vivo.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SI2PR01CA0001.apcprd01.prod.exchangelabs.com (2603:1096:4:191::13) To KL1PR0601MB4113.apcprd06.prod.outlook.com (2603:1096:820:31::7) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: KL1PR0601MB4113:EE_|SEZPR06MB5763:EE_ X-MS-Office365-Filtering-Correlation-Id: 3710c400-4478-4936-f0ee-08dcc5aec2ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: rmnEQspUpobzu9gf6aoC72Ht0KPXIg40CPpHtlq2AVVr96LtfCnRVdGM0TbXA9liLprliGT2Q0HoYS/uiZElK1PogMyXLcwSRipNNeshMqaRO4Dm+7l0n8l7maagtklRKXyRaQRtFpjeghHqutx8OW7WcSoGzyW+t+LGUBAJd1mtnceeFuKqwKbvo7IC5zik8ybkY1I6HGExN+flr3M8cqRqPmP4b08B2sCcBfilSyOqBlRzU+sEWsclCzIfFDCJDqNh4avEq4fj0W01AY2+MV4Hxcraz7myW3aWbpsH8CUj2Cz2UBUrAYPUqkNC/M0wJG3jA3dWl0SN4OsYhfMsTN1x0muN6sk66GHarENGoih9EuSibg1+hwvdIPURlVOQeD6YHl8AyUC0pjHqKGPfAEqYI63K6ke60+8IJ4e4A2QfW7klM2+mZzQ9fAE0CG75IXjSfsouLsyHZOqQsJpPd1C8Bnd2uYf9Pt257Eg5M3JiHNENY3hVITgFqazAL1TKnN8JxPXxGitiB5gJzN0XNBaIW+jY4k3gbYTIWl6+AzuDHcnyVtXPmZqW3XY+rpq0yyQitHMIL/uoUIvFJeX4e/+8aTtDy8XxQeM63himllx6un2wBZuKYiz8rbkGt5WV8ndEezim4Gp2z0IxGebhlYhAsiE5pBqvisYrqCxQBy5mqGhU+BdbdahNw4YBhKNtLmMuE6AbY+F6lDGSG7EDylc+qE4pIdp8X6N6BVevSauOEqKL2tEEt8jFe+SzrOxKX+7SCPQ+9A0acPOqaWtGVivBPWLoA+JPhZUXiLGtrnjp8XwKJLxZd81yqLgSTLJCxwVoN56XNomD2XVhHeuG81gaQKah4lCJWgJw1psHsagRje4pQjGDf9Q+tOpWk6CRypOmANc1Bv3iNXZdkAuuBiYhfjixIh1tCUy9A1uGbCJugY4+W0GAVp8cZsQR3J3v9VrDD165mxrrb1Avj3Vk4r5Oesj+Y+RXZivCug1jJ4IswuiuZcAMX6zUsaDr6stzTxLA/KTe37iVrp/+Sie6EFsQoAXuR7uK6OGA9NkY7pIAGCNCFoLxSy1dOAgV228eq2FMcLX1TigJqschcLlvLnJVO0OYhkB8YM/cjBk8Rx12ZXG5dzspGTv5VWDL1QfEfgRaHD49n7g8nQ9e36Bdk7j3Ac4c7t2mCLyM9WRcILU2qD58YVoKMz1U+mm5a+2p1IHU1kF3472P86nCvSao5FvPWx3Ebx5Jv5Kt3OA7xJiX9cle51FEW1K+8k5AVH6n1Kxq++6O7+LsQF9lMQSKb5L+cck6887khZBGDpKjyIxbO4eZGwYMn4bGB1ge2KUGCrw52Q6fyyOEGx4mp+1JbsGD7V137PxU+7ndt+L6RSQFDnWerO9PldWfZm5kYbZXk3HFW2Gf04tELLf/Uj98ZQ== X-Forefront-Antispam-Report: CIP: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)(1800799024)(376014)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-Ant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YbSxZdib9OvGYThUkacZ6xNv8J3zcJ+yMfcBWEdzyB0iblPH3ZOQZn3rzV+iEUGB2xyjrjMIDPa33dwOsR2FBOE+XLnpTk7EjhRQ+Pt5hoH5DDP0zcbkwq9UYzR8pQ6p5m2ol/qNZYPURt7aEuv2WxXNRzOnjoLO7JZ2Es2yKh/HObg6zYgdKPe9ydwfjmCLP3RfAgKek4sP4McGjmfQ/fSbgZavOXi+m6Ie9jbGMdH04xJwxYj/mIyNs11HIAcFnYN53nI9BSSj2SGfswv9Dc1VpnWC8t8eab0uSI+BaOXJsNkiYd/pFVjzz8SQbswvPdQ+9Rex1q7loUZu/VuweiH2F2L0jCf0YIIywvKVU75clPfifLnJhN4DicaWb67MPN9/P7QTvVpYeWNIp5/QIYzTj/JycyolSd6jREcp+UrdPSZhOydZMwghSa66kSwZWu2QSBI+hWS/sic0Tv9KEyB+JibJtamkd06VrXq8cXLO3GNz6Tm4eQdgj1zafjCx65xflYCYpROurt2EnJMsd2NjNvkcWRtz+4qKtkYm5DBpWXvuXagKsZdpyZEDOXbsihgdngOWeK X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3710c400-4478-4936-f0ee-08dcc5aec2ea X-MS-Exchange-CrossTenant-AuthSource: KL1PR0601MB4113.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Aug 2024 09:09:17.0577 (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: j8Xxsm+MkbsD6z9q6lThxHDgwMP7Y7+V4QuWbQH+35nbbukYyTA1Bzrr2GntPblcJpFe+WSygc+8bIVljbAoJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SEZPR06MB5763 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 --- fs/proc/base.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/proc/base.c b/fs/proc/base.c index f83d41bf155d..e08b36dd4766 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c @@ -2123,7 +2123,7 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx, ino_t ino = 1; child = d_hash_and_lookup(dir, &qname); - if (!child) { + if (IS_ERR_OR_NULL(child)) { DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq); child = d_alloc_parallel(dir, &qname, &wq); if (IS_ERR(child))