From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 305FC43CAB; Thu, 14 Mar 2024 08:06:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BF5AB42E8B; Thu, 14 Mar 2024 08:06:17 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2109.outbound.protection.outlook.com [40.107.220.109]) by mails.dpdk.org (Postfix) with ESMTP id 0EA6E42E7D; Thu, 14 Mar 2024 08:06:16 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b4GZazPerowVU27ahTeh1a/b8lnGvq1u2y3baUvXgNRp3OHFotW6sXg6e1AW/AJsSbeYz/qeqUyBirleh9ebiNzU1Gn3M22Wgco8aKYKa5x5koJ+3Xw6tqih9KG6OJaFN8ullExVSw7ax3md0Gi/3WcMFtXAI3RLLrJMKscYEnqdD4r2RlUqEs+5VbaQK1lSbgM6T2jqeCG3482mP2ZKZMP2NHWK1CBSYfdBDQzDZNidVnamxa3AIuZ9dfMhIIVTyty3EM/npEulTXUPntRpZpqjdjyiWYmSpoLYzi4oI5RUW+D9nXSMXMddEqbt/X76EwSc2PEn2iA/+YJdwq+4Zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=byfzGYTm0KCnIF14nNyHqdujt6PmveJmOG8kEXXL4OI=; b=Lg7QDDCW6Yqood2We7dlapnOzkZXfOIAhIfrJn4QLBudD4TaWpXJvDzl7O7E1jeVXRhS+qjoSooxyw99fgPKOseidN9DjTIm7Z559xsvC9D3AjBjyKefoNv9Z+4F+o8hyo2JJGNQUSLTPTQ6LgfWQ4jV8vyGUqzAvdaFoyALNRkC+ew3Z0159zkHG8EdBcpbQz5c2frIV2t40quqSvoQABq/nqYciYa/edgllYTvc4GGtcEkMVObIbi7P12ygCjNuit70dFO15Bls6oo38n1LRWdINMEOfCvd8/gUBX9/D5CLlklCfPghdbJt2aaKQ/PJEGXtr9ClyoHLOakMD7JQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=byfzGYTm0KCnIF14nNyHqdujt6PmveJmOG8kEXXL4OI=; b=hQ0LZD9lst04kXGM+mUcOiutGJiqzxBCG98ORfu2gXEQ3oug5rXZlwJM7R4vNsG+1fpxt2nDGJqLK3H0OHotP7+B90jOMyDB3AJyWffWq/fT0FrwnEviQcdtrfUy2FJ7GVoJeTz/GX3YLJy0JhUQlL4m68cqFzI07OtmScjhcKc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) by DS0PR13MB6235.namprd13.prod.outlook.com (2603:10b6:8:115::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.21; Thu, 14 Mar 2024 07:06:13 +0000 Received: from SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e]) by SJ0PR13MB5545.namprd13.prod.outlook.com ([fe80::ec12:7411:559a:850e%5]) with mapi id 15.20.7362.035; Thu, 14 Mar 2024 07:06:13 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Peng Zhang , stable@dpdk.org, Chaoyong He Subject: [PATCH 7/8] net/nfp: fix dereference after null check Date: Thu, 14 Mar 2024 15:05:35 +0800 Message-Id: <20240314070536.3169210-8-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240314070536.3169210-1-chaoyong.he@corigine.com> References: <20240314070536.3169210-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SG2PR06CA0191.apcprd06.prod.outlook.com (2603:1096:4:1::23) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|DS0PR13MB6235:EE_ X-MS-Office365-Filtering-Correlation-Id: 40b08fca-952e-48a1-6b61-08dc43f53be9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JoMy1H2ocCjHJBUhkBllouyNHpLJSq48KP2OBcEdRSHQ4ie2+/6ja7+Oxj35d3vF/qWTH/YfeU1Wj1uKs62FDNKX+OV8W2G3ceUW5Q+QVpYCb1/zMtjUXqvYdTB8NNB5LGfutMEDc2itG4Cy+04Q4qtMjNf5LKoeS+CMGViAEFSMKyc06a7enBkvTkcyjih01E/4xVyf5cyyAEEtxsyHWZShLSaj2nC/Mwf529r4Z12AUu+Gh1DQX+AF8qpz2d4sQbaniUUm4cbYzXSr1jQewL6yOi8F3etFUaSte5sMX5rck92sDzMol5zGae1b2Pgswh4g/PyBGkrWuQPw/xlqT70aek2ET/MI61I4syNZKhmDMQ7kDbauKtTB4XfSRzdav8Rc8GBLu00iDWTiMCsdzRkhNoqS7PXe4PiRhQwK5o1tS6nKVvT6nlJH5OBMgL3EnXtrGPC4GKCNjN5VwVPuFeXMlqKVVGz5s1ZCGaYFowURCC5rM09+OYOz0hRPUG1UKzfk8AqXmFtf7iCz7xkx7Z7dax9LFbecyvuw6C42AHvO+PI2xuUcex4MaOlMSTDDCQQDw1dOOFYpoewr1hFuQwZrzl+PCmpwE4zRJpXQwBkmOsoCrawXJiEo5NV1d7EKNe9sADTD7O2w9bXrE9AYQSzhnid7OON3CbC5ozxeINLLXWY0TT47cErWgs2eJvZLxHQQuOxRgMbkaBFaTUBI+DrQI8qUT1hVcW8sUHsDcmI= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SJ0PR13MB5545.namprd13.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(376005)(52116005)(1800799015)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?dkSLKMTJX8C/ZbQgX/3RZwH5ZuiFLNCW06E4/fk1Ik4Crtl575iIzwR8z3MQ?= =?us-ascii?Q?Wj7gEqPh3iUxJ79+Y5HmLpdTwuysVczZfv2OmdnXJhUJvT87LSqy0p8pbxIE?= =?us-ascii?Q?E0OOyYyzxcls7NmcncU86G6J+wjuaYFgNdZWvKmmVyrijmg0dMD7b2hjQBA/?= =?us-ascii?Q?gXzijL7TMTfgVdoPaOvR5uX3k3Ols/5eeLkmgNXeRJG94ddhB7tWIxTAxEFf?= =?us-ascii?Q?XqrN4gvngiPez7GkfgncvXQNUYuHGRfJF/a2NlUH8KtwCLoOS8SZVCHKzcaQ?= =?us-ascii?Q?YKFeqO7y7zv1EZJPyXSgGYHyU+7c4iECbBr2FhALW3YMOU0ywgoCVjmLMJm9?= =?us-ascii?Q?LIFbfPDfvBfb3XMcpkj1Oqr+El5rC1VmmjgBq59GMNsdw5JSWfTBYeK77lRI?= =?us-ascii?Q?Q42KfBTAr0tQ29pFudAV9MtIn/zYeh5CqILUrCbDpnPl6AueSphOObGyVX+z?= =?us-ascii?Q?p/f5k2VuX1IFfGiABM8CXxs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q?a5KKKEsr0E3z8ox3syYqt6A3xQRX5Zohv3GNClgDjaAs/WKUdw87AGvU7sT7?= =?us-ascii?Q?GEUSKc4lnGimkqYP/l57DIKRVFqohEUBQdoqlq7ArvWjfnhA863gxmTwb64m?= =?us-ascii?Q?6EPVqAJhb8z995+1rhzG8gw3zAnrO8//Kz7p5JDC6/2yhyxlPB8QG6uQb/8f?= =?us-ascii?Q?Lpg5KWy28kNOyKUwyjcghL0huLov7yvrqdF2VXTD8h6Z4SXLReeSg63ET1S+?= =?us-ascii?Q?1g=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40b08fca-952e-48a1-6b61-08dc43f53be9 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR13MB5545.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2024 07:06:13.3880 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /jPqvU+LJVWg2Yyhcxt7dZDR3+zJv2lIuWUhJ/hQCCA6YqYkgMeTS7XrLJGFOo6M3nRirK927CbmRSWZWJoOpsQwGyeEClsWEjjSJT6DMnU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR13MB6235 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Peng Zhang CI found in the logic of 'nfp_elf_read_first_symtab()' has dereference after null check problem. Coverity issue: 415042 Fixes: c82ca09c441c ("net/nfp: add ELF module") Cc: stable@dpdk.org Signed-off-by: Peng Zhang Reviewed-by: Chaoyong He --- drivers/net/nfp/nfpcore/nfp_elf.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/nfp/nfpcore/nfp_elf.c b/drivers/net/nfp/nfpcore/nfp_elf.c index fbd350589b..268cdb1aff 100644 --- a/drivers/net/nfp/nfpcore/nfp_elf.c +++ b/drivers/net/nfp/nfpcore/nfp_elf.c @@ -900,7 +900,8 @@ nfp_elf_read_first_symtab(struct nfp_elf *ectx) uint64_t sh_size; struct nfp_elf_elf64_shdr *sec; - for (idx = 0, sec = ectx->shdrs; idx < ectx->shdrs_cnt; idx++, sec++) { + for (idx = 0; idx < ectx->shdrs_cnt; idx++) { + sec = &ectx->shdrs[idx]; if (sec != NULL) { sh_type = rte_le_to_cpu_32(sec->sh_type); if (sh_type == NFP_ELF_SHT_SYMTAB) @@ -908,6 +909,9 @@ nfp_elf_read_first_symtab(struct nfp_elf *ectx) } } + if (sec == NULL) + return -EINVAL; + sh_size = rte_le_to_cpu_64(sec->sh_size); if (idx < ectx->shdrs_cnt && sh_type == NFP_ELF_SHT_SYMTAB) { -- 2.39.1