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 95FB843CAE; Thu, 14 Mar 2024 08:41:45 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 445AB42E86; Thu, 14 Mar 2024 08:41:01 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2100.outbound.protection.outlook.com [40.107.236.100]) by mails.dpdk.org (Postfix) with ESMTP id B0E3542E85; Thu, 14 Mar 2024 08:40:58 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CfRjEeQKmFAFaht3yK9uIuxI7Q/wqCxwjTajxm4gD95e6oovFV0WlbsZe2G8PRsVjJQV4WUmi2JZ0rwQMdmOGUgjc3T/yiZ/U8HMxdc654NVVaINTl6rhL/YL8iIH6WkUd6I6HhLT5ksLTWqxflnpzTr8hSskEPd3KM68r98Z3FTmIcWkZsyVWQslDutnCJxcmLVG9XXGHdkCT5y6IEAMU+e/qTKfqZNrvEU3xKhVnYHHRHjJNaeloDuU+zuwj9bhASrmiteev0gCJGNdwadlRacI+Za3MuNWnwmIFPNSHy+IYSavbmOZaT8AcNi+JMVkgK88FioM0C/yiuCjDrYDw== 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=blmJfntqQa/zULAjioHgjzfl6fR2hpSeb7LnNJBRibw=; b=MCzfL74jPCUTkFtU2vwL0HblYv1FwZfa2rvsep+WlnLHLdxg570YOhva25SBYC1SgTwBbn/B+p61eLMqcehfm9uiHc9CSPQikThjkCYQ5Wq8VtS4NdoQHd35ICyZsgVxuutIJ0wA1M/uIcmuBecY1wZQcvEzhuqIaKxhxp3xYVJbmpxFoZs7A4zHIvmHvG1QRJQI5PAEk8LXTkHF131AiXDyDPaeNkd9uevC+jcY7Xnn8LW/mbokncQqYGkb0u7pUNOt91lVh1wDuWxthKZzhW3dQujU+Ros8VNT1a8vBevZvSvQFnVg7qvldN3u1pWgGY5Wkd2OpzvXM/38ukjxQg== 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=blmJfntqQa/zULAjioHgjzfl6fR2hpSeb7LnNJBRibw=; b=v/YizlepkgwZ4kfvoEvn3tQrf/kg64hMFeKqCRnT9Nxo63BwqAnGJB4Uuur7qm453rwDWqQJg8co6U1j4jH4m/S9Raq94t2r2ruFYMdEDLyKyDPNqOZ9M/2w/zpIzrKj47obVx9pWMi5jCG9yiPcffpwGtrXQwacFkH8N7OhsGA= 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 BY5PR13MB3617.namprd13.prod.outlook.com (2603:10b6:a03:21b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.19; Thu, 14 Mar 2024 07:40:57 +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:40:57 +0000 From: Chaoyong He To: dev@dpdk.org Cc: oss-drivers@corigine.com, Peng Zhang , stable@dpdk.org, Chaoyong He Subject: [PATCH v2 7/8] net/nfp: fix dereference after null check Date: Thu, 14 Mar 2024 15:40:23 +0800 Message-Id: <20240314074024.3199555-8-chaoyong.he@corigine.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20240314074024.3199555-1-chaoyong.he@corigine.com> References: <20240314070536.3169210-1-chaoyong.he@corigine.com> <20240314074024.3199555-1-chaoyong.he@corigine.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: BYAPR11CA0107.namprd11.prod.outlook.com (2603:10b6:a03:f4::48) To SJ0PR13MB5545.namprd13.prod.outlook.com (2603:10b6:a03:424::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SJ0PR13MB5545:EE_|BY5PR13MB3617:EE_ X-MS-Office365-Filtering-Correlation-Id: f70018bd-2747-463c-743c-08dc43fa15f8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eMmAIXMJSsLJa4JbFthxOJLkMwCheLxDmBofRZ1dDmTajhA5TGPsh3AAuOEP1XgJUNwMkNvKv9K8TsPKQQ2jnx6ByW1PFJH0hiTnY4PzZbbOKddK6WDi278+kr5jsOGu/N3pgSOhgszJBc8B7kcIh4B/QcwFFvhcS9A2SL7AO2T6gmBEpRiy2/ad4fyULBGyGzlgrZ+MTwQANHVn/f3nhK7DbSTH5pLt7rplOVF9LnKxoA7nrZQG+v8wG/B0CN6hjNAyWvXpbgjBXlYmTqe2CeZW69wB2acxOdhoDGMeF3ASc8eRIVmdsadZIsiZZ1HbPblUVS5KnEmiaqmU89BlwCqkSdcu5GP/QD6E4AcCaZV05Kda3UyPGjBagcq0KTHW/5LKCnNIdT/p4M8sSELBNw24nvg/MedcR20pgZkw+K6yBitNaRkJhWayzHCgN/jv+GHCuItLkAWS/cDZMW9ZC+71o1qhk9ya4EDp4XQU9mXQrA4FlqUu+ST6WWImGKa8NbEHVBUZufXQ0rAap/lakShNwSXicfW/Rz0Gxlf4lLKP6noLVPr7UOpaevWvD/w+EWXXeorzYPCB7iZ8u9hANNbdnTue9hybPX1cMS9p0Eh6teukZFjPYAuBmTyHDEEM8+zZgqZI/tn16FLqtC6HeFdClGpm+mPhKWdH/Ru4qAy6OP6s7qWL6vdVXD8kBxgJz6wR7JtXGch1SWP8PKzIFUk3SAV94WLEDsMX7BkXBHw= 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)(1800799015)(52116005)(376005)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?zTst+fKvJyQK5eiiEh4YzraL3C3jpQJUj3kea2Z3SCVR32XaSndvZnR+aJpN?= =?us-ascii?Q?Yl/q4xTlCqUyCaJQ2iZD1RyQqEMu/EnBULyh3OqLtb6CLRVujpPY71HjTAg1?= =?us-ascii?Q?0Rggc6D9XqSzXLe7Utq3C5DDaUcLwWsaGfOmbYcWZuT5sgno29vhJUjTTcid?= =?us-ascii?Q?WQ7zNvebV+Iu3n5dr6j9+lv3YFgyRYnMfarslq3wOqydfTMcmzeYhJ+L272R?= =?us-ascii?Q?4SXbQOhDw+jYmlMrunM0kq9NCDI5c0tfOEBD+tCbOQjPSVWURIWQgmu20XsK?= =?us-ascii?Q?VumjDJ2qmEmln9L81Tlszz09efMWI7Sp/2vI9yAUXFNO2HUMBiHhMrn+U1ue?= =?us-ascii?Q?99/XBbhy/vcyjRIYTsYuEIE3g6TXVjL8yvVib4ZPY7ke9gOC9fnRDNDfVgtD?= =?us-ascii?Q?Y7NULFIop+faPyPl+yG2ta89+Vj5NipORRj+CD7wz1ncCA1eyye5W7x5ma2I?= =?us-ascii?Q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j1dfEXXZTGDOgC0E?= =?us-ascii?Q?QAOBw/B5V7P+43UKCH+3+AzbCWA1ZrXzrLxbaUtcbtoxGri2xDHJnPTnvv9t?= =?us-ascii?Q?FFBqlfDWcey99zegYT4pKutdQKS7PxiicPuklBsbAYHuZE7P9Zsno6wdYB1s?= =?us-ascii?Q?iFcS6tue+A6xGqjmH8HVZDSyOzp3WXxvQa4CAVl8fn1GuI5fRds21mS+YaLG?= =?us-ascii?Q?nwGc+iunfw+6re2ueBdMbFZmIEswrwiMU3lyzKQR4xAt5l+B8WjvMaS2xQal?= =?us-ascii?Q?WA=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: f70018bd-2747-463c-743c-08dc43fa15f8 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:40:57.2048 (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: iRXfJt7rnXzYudMB4aYDVLagPB94j6na7COztVGKw6HD+ek2Az8OvMIwlgaj3mMTZioDB1MCz0Vs4XwZ30sydeweTMAIp0sjTNMki6qQdMQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR13MB3617 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 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/nfp/nfpcore/nfp_elf.c b/drivers/net/nfp/nfpcore/nfp_elf.c index fbd350589b..1bf68ab3e4 100644 --- a/drivers/net/nfp/nfpcore/nfp_elf.c +++ b/drivers/net/nfp/nfpcore/nfp_elf.c @@ -898,9 +898,10 @@ nfp_elf_read_first_symtab(struct nfp_elf *ectx) size_t idx; uint32_t sh_type; uint64_t sh_size; - struct nfp_elf_elf64_shdr *sec; + struct nfp_elf_elf64_shdr *sec = NULL; - 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