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 C63DB45AAF; Fri, 4 Oct 2024 17:56:55 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A827342F31; Fri, 4 Oct 2024 17:52:03 +0200 (CEST) Received: from egress-ip11b.ess.de.barracuda.com (egress-ip11b.ess.de.barracuda.com [18.185.115.215]) by mails.dpdk.org (Postfix) with ESMTP id 8F95C42F01 for ; Fri, 4 Oct 2024 17:51:59 +0200 (CEST) Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05lp2175.outbound.protection.outlook.com [104.47.17.175]) by mx-outbound22-159.eu-central-1b.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 04 Oct 2024 15:51:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=l2GLFXD+8og2tYgHvTmqv63MPRTxV+y9HNwZzcP8SjBnrDBs8UF0jdsB0RqbpRex+nha705aReLnY2iOdOWFbtlhe91AFeM57OUt4UcYO+8EmjAO7hAqDArYi2Cg0eVmZPd+p0apZUboUqZKAF4o6tk3AmCQE59Rfa4nPgLnZ1UFg4PtsaSv3fwGSAgNaF2uymDH4Z42QaOHTt3oZ3PhB85XXjHNi0gr5I50gvzdCQKo8nRxuDwFEz/B7EpngNpz4nqw7T9G6pYQYn+bnsUeKJNaz/jif8STVfMZgwveR9tmnaw73t/d3mq1SV53PTsM5fv06xmNjE09WAL/49ekQA== 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=PkI2O2Yy0dRfXTgFsOREU5r9N8GXa+7OoFMHpWtWl8c=; b=NetiM/79+XP+lWSgK5CLWPLjwdT1OqHPH/uMGWPdxA45yVO/+g2c54T5FXYrGPr/JPmG9FEEehQdkrrm1N2N5ieoJcT+HdDYYvnIVRPDnwSVXJLdZpAi5gJkHxxHz7kVhiI1fBIYsBomMxD/JkchkL2liIMIFvfwGyxARciFt273vtdlDkSC9AqiIOzffuVOOpyDSncKsCdRfMad6t+puM7rnLZ9uyIth+LzcZsP7WdQqk+tTyNIwuS/0GJ+uWtxZbB/HPB4hXJoHUqln6HowyKgS2hFOjedjynFfTzMGlllt+Rur6VbHSIN3gTfCpMNDKpLAhYIAQLH84IMLDTQbg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 178.72.21.4) smtp.rcpttodomain=dpdk.org smtp.mailfrom=napatech.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=napatech.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=napatech.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PkI2O2Yy0dRfXTgFsOREU5r9N8GXa+7OoFMHpWtWl8c=; b=Ce5K/xY8XfdvuCK3qu79RaISEy62VFUzm3ZIgT6Y1GeVt4hYeH7RtLRnGAUO9MtlKoh6FY9Z3VzMSC5lDLzkD+3r/ciEnOJsk0kbb0JqqmoOdcaVDeX3gPSTuYalvW9WlBYc291xhO/SUguuTurV+BAJ/8xWZBYVUvg5EEcEBv4= Received: from AM0PR10CA0097.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:e6::14) by GV1P190MB2080.EURP190.PROD.OUTLOOK.COM (2603:10a6:150:16d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18; Fri, 4 Oct 2024 15:36:02 +0000 Received: from AM2PEPF0001C715.eurprd05.prod.outlook.com (2603:10a6:208:e6:cafe::c5) by AM0PR10CA0097.outlook.office365.com (2603:10a6:208:e6::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8026.18 via Frontend Transport; Fri, 4 Oct 2024 15:36:02 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 178.72.21.4) smtp.mailfrom=napatech.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=napatech.com; Received-SPF: Fail (protection.outlook.com: domain of napatech.com does not designate 178.72.21.4 as permitted sender) receiver=protection.outlook.com; client-ip=178.72.21.4; helo=localhost.localdomain; Received: from localhost.localdomain (178.72.21.4) by AM2PEPF0001C715.mail.protection.outlook.com (10.167.16.185) with Microsoft SMTP Server id 15.20.7918.13 via Frontend Transport; Fri, 4 Oct 2024 15:36:01 +0000 From: Serhii Iliushyk To: dev@dpdk.org Cc: mko-plv@napatech.com, sil-plv@napatech.com, ckm@napatech.com, andrew.rybchenko@oktetlabs.ru, ferruh.yigit@amd.com, Danylo Vodopianov , Thomas Monjalon Subject: [PATCH v1 2/5] net/ntnic: fix coverity issues: Date: Fri, 4 Oct 2024 17:34:20 +0200 Message-ID: <20241004153551.267935-3-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241004153551.267935-1-sil-plv@napatech.com> References: <20241004153551.267935-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM2PEPF0001C715:EE_|GV1P190MB2080:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 20549a56-3809-4807-a231-08dce48a40a7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|36860700013|1800799024|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?8V9yGbC3c5rDHDTvz0mFGCI93qD4szi4aAy32/XN90KF/nNuEzAiyrLO0hCU?= =?us-ascii?Q?zL6ua0qy3C+NXH1/8bmS+XBqg/68CW4pQ0uIVxKqS9E1tiHNsFP4Nrdk78T8?= =?us-ascii?Q?F4Vn7aaEYj6zb1G4hioITmEcp+tpqmy14kGXNPb67vx6lMiJQa9WQMOEDuuy?= =?us-ascii?Q?wWTEMWev0iymI4W7JVu4OlusS1zpGYH6AsO9cckfZ7X7Stxb2D6i7WfGevaU?= =?us-ascii?Q?cMvIFvklwQJfnKAlnpNi7gyyKMG/FiH9O+RNJHLsQQhrxGRNOeYKGiwsyBZa?= =?us-ascii?Q?xON9/9IdhYObD7rqVpEG9KnXpuqRs8PHtvBDmn+PjsfhN937S/9E+0yEyy//?= =?us-ascii?Q?c50nGRC9FUMquv86QP7cuvqWdm+IIT0f8a2l/Blq1KPyZy8EkXEqePUTRzHX?= =?us-ascii?Q?gg1d8znbDkAHo5mg78nKgg7ySID6OSxY76obEov8ipFrv+eHEIrasAKZ68W+?= =?us-ascii?Q?pQVMlvd8EBwjShgSmu6ZOGncADjWtafGQPl7q6/Dco07+twYvttvUnto6Ymp?= =?us-ascii?Q?J4YEIF6HuAZo409D2jOVL67t2uPIjSsT/yPptwN5P6BMdYpY8vHlBOJwAcWT?= =?us-ascii?Q?iIGV30pW6a40XVKEciCD/tNIyHnk8rXVa1t2inYmLAH0guIK3tF9k/GFeWA4?= =?us-ascii?Q?kxirfZciZsYUO96gfhijeI4tZkU9IJnGYQ+o16ToN/SLfU5UPNY7wzJxBO40?= =?us-ascii?Q?yg4ZliD/vVHhJf+R6UEc8ZAvevZ5ghjyEwBHRgoLjYM5RRiEvJam89TybWO/?= =?us-ascii?Q?4B15hSngKIlskTJTgpi/Sk1hy/Wkq5BkIVFgWcoZ3dJ5r4+6DCOgBNyQMq26?= =?us-ascii?Q?yRkyUMV5B+zkiKVpk4R0FtBi5DPbqAXnMz6Yz8gfxwsqhTkCX9+Q9qw3z7g1?= =?us-ascii?Q?R4kfokwOE50B0rlAs0ApD0xrgI/uZPi0zS3psUzpN7DuqVN1/uUBO/omlKKF?= =?us-ascii?Q?XCTMcziMRdDzWNnoEbU4lq71MWu9Rt32YdZuDvJ2+HRqP0lIr4LAyw5Jvoe3?= =?us-ascii?Q?VxWTj/5y8L+juDjp2rpBmCorMq3p03tSqGmhMtiGyiF2n5mzOL0PT8BdXFEE?= =?us-ascii?Q?pVlqbrWHGs4f3FpphS3lKlUnUJTbMMjp8goPQMVKSgYCvR+ZuhccIg+6vlBD?= =?us-ascii?Q?3eh+gYxm/VQPilC5DSCjSqbA2cYE/lSMMKhjDJQxPTevHT5yjxjAdxA4tfUr?= =?us-ascii?Q?yXGOyIE1Ovk8/vvavH7kQhhsGYNl+5oM/rtyO8PkHM/AKMR3RBJpY/ejnJCO?= =?us-ascii?Q?14KMYWtl4czhttI57I2T3nofKre28FOpgsaGSvX7KyESKEusiUFJ2blZ57Sk?= =?us-ascii?Q?u9UH7glN2si9BDH5yjXauYOz68ZrRphhWoZvgQ2GZR6psaqenDG/WeEkAkoI?= =?us-ascii?Q?/EgT80/DNRBnsZz7KYu4jWl81J9N?= X-Forefront-Antispam-Report: CIP:178.72.21.4; CTRY:DK; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:localhost.localdomain; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(36860700013)(1800799024)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: r6u+7KrUb5Rh7t27+1nISnmafCx86XD8OKlIkjlRGXPbltquLG4Lep31f0hsXCVKh1Wx0/HhhpM2oP9p548JJ1a3vMJHEN7CanHMJpEjrcx6/uxu0uuYZvvN9m4OT23wz3hHbtnpCYbhk3pAxz6ebzsyfLUypHwm0haPBW/4AQFNIsDiCuweQNGkVvZ+K1oDUWMLd6Yk4liDch7m+aPdGskf9OIIzPchSmpJWPhk+e7ZGJsO4gp91JSEe0jCCLkVzZbCR30cKR3cliBxm97wU5i9+j6yCcgSgTliTkuToPO/y+1SQe7fWDcSDAjFqJJSoB3aY8hzpcQ1YePZrm1pCkDvJP1MabNBAW4ZQ079w9K+3QcY2SHgYdP8AK6LpAHlndl3rf5vfMlh615IgNVdxvmqubX57IRng+ExssdbJWYm/u3iPewamBFgc2EHFyIkkt8XV6VVv0WUP/kbk2Mi0C5INZuK4/GLRaQ+SW3c4bOcQVjcjTVwkA38RC2C4B1xga2j8HxP/JvK32uwbSg/o2cehpy99WgZUPu88lFla/7yqR6b2jOSJg8x6PV/NqOChtMrOkEiBCxXz0Ur4X78mls3fTNk8cGRWvo0o/YXBBXyu9n0GP9qduMJdIS77d0Fx34kjE/8gdYuIOdo/OGPOg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2024 15:36:01.8771 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 20549a56-3809-4807-a231-08dce48a40a7 X-MS-Exchange-CrossTenant-Id: c4540d0b-728a-4233-9da5-9ea30c7ec3ed X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c4540d0b-728a-4233-9da5-9ea30c7ec3ed; Ip=[178.72.21.4]; Helo=[localhost.localdomain] X-MS-Exchange-CrossTenant-AuthSource: AM2PEPF0001C715.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1P190MB2080 X-OriginatorOrg: napatech.com X-BESS-ID: 1728057118-305791-12642-36072-1 X-BESS-VER: 2019.1_20240924.1654 X-BESS-Apparent-Source-IP: 104.47.17.175 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoaGBgaGQGYGUNTM1NLQKNUyzd DAyNwwKcnQyNAy2cjU1Nw4LTHZyMwkUak2FgAsB3MOQgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.259494 [from cloudscan23-144.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound 0.50 BSF_RULE_7582B META: Custom Rule 7582B X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND, BSF_RULE_7582B X-BESS-BRTS-Status: 1 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: Danylo Vodopianov CI founc couple coverity problems which were fixed in this commit. CID 440550, 440551, 440545, 440553, 440552, 440547: Null pointer dereferences (REVERSE_INULL) These issues were fixed by reworking variable NULL checking and adding NULL checking before var using. CID 440543: Incorrect expression (IDENTICAL_BRANCHES) This issue was fixed by removing useless if statements from the code. CID 440548: Null pointer dereferences (FORWARD_NULL) This issue was fixed by adding NULL checking before mp_fld_rst_serdes_rx var using. CID 440546: Resource leaks (RESOURCE_LEAK) This issue was fixed by moving NULL checking before var using. CID 440540: Error handling issues (CHECKED_RETURN) This issue was fixed with return value checking adding. CID 440549: (OVERRUN) This issue was fixed with array edge values fixing. Coverity issue: 440550 Fixes: 51052594f795 ("net/ntnic: add physical layer control module") Signed-off-by: Danylo Vodopianov --- .mailmap | 1 + .../nt200a0x/reset/nthw_fpga_rst_nt200a0x.c | 2 +- drivers/net/ntnic/nthw/core/nthw_fpga.c | 24 ++++---- drivers/net/ntnic/nthw/core/nthw_hif.c | 18 +----- .../net/ntnic/nthw/model/nthw_fpga_model.c | 58 ++++++++++--------- drivers/net/ntnic/ntnic_ethdev.c | 21 +++---- drivers/net/ntnic/ntnic_vfio.c | 5 +- drivers/net/ntnic/ntutil/nt_util.c | 3 +- 8 files changed, 66 insertions(+), 66 deletions(-) diff --git a/.mailmap b/.mailmap index d2f30cf8eb..3ea3a70762 100644 --- a/.mailmap +++ b/.mailmap @@ -295,6 +295,7 @@ Dan Nowlin Danny Patel Danny Zhou Dan Wei +Danylo Vodopianov Dapeng Yu Darek Stojaczyk Daria Kolistratova diff --git a/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c b/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c index ea0276a90c..aa0d97dafd 100644 --- a/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c +++ b/drivers/net/ntnic/nthw/core/nt200a0x/reset/nthw_fpga_rst_nt200a0x.c @@ -263,7 +263,7 @@ static int nthw_fpga_rst_nt200a0x_reset(nthw_fpga_t *p_fpga, if (p->mp_fld_rst_serdes_rx) nthw_field_set_flush(p->mp_fld_rst_serdes_rx); /* 0x03 2 ports */ - if (p->mp_fld_rst_serdes_rx_datapath) { + if (p->mp_fld_rst_serdes_rx_datapath && p->mp_fld_rst_serdes_rx) { nthw_field_set_flush(p->mp_fld_rst_serdes_rx_datapath); nthw_field_clr_flush(p->mp_fld_rst_serdes_rx); } diff --git a/drivers/net/ntnic/nthw/core/nthw_fpga.c b/drivers/net/ntnic/nthw/core/nthw_fpga.c index d70205e5e3..082d3950bb 100644 --- a/drivers/net/ntnic/nthw/core/nthw_fpga.c +++ b/drivers/net/ntnic/nthw/core/nthw_fpga.c @@ -217,19 +217,19 @@ int nthw_fpga_init(struct fpga_info_s *p_fpga_info) n_fpga_ident = p_fpga_info->n_fpga_ident; p_fpga_mgr = nthw_fpga_mgr_new(); - nthw_fpga_mgr_init(p_fpga_mgr, nthw_fpga_instances, - (const void *)sa_nthw_fpga_mod_str_map); - nthw_fpga_mgr_log_dump(p_fpga_mgr); - p_fpga = nthw_fpga_mgr_query_fpga(p_fpga_mgr, n_fpga_ident, p_fpga_info); - p_fpga_info->mp_fpga = p_fpga; - - if (p_fpga == NULL) { - NT_LOG(ERR, NTHW, "%s: Unsupported FPGA: %s (%08X)\n", p_adapter_id_str, - s_fpga_prod_ver_rev_str, p_fpga_info->n_fpga_build_time); - return -1; - } - if (p_fpga_mgr) { + nthw_fpga_mgr_init(p_fpga_mgr, nthw_fpga_instances, + (const void *)sa_nthw_fpga_mod_str_map); + nthw_fpga_mgr_log_dump(p_fpga_mgr); + p_fpga = nthw_fpga_mgr_query_fpga(p_fpga_mgr, n_fpga_ident, p_fpga_info); + p_fpga_info->mp_fpga = p_fpga; + + if (p_fpga == NULL) { + NT_LOG(ERR, NTHW, "%s: Unsupported FPGA: %s (%08X)\n", p_adapter_id_str, + s_fpga_prod_ver_rev_str, p_fpga_info->n_fpga_build_time); + return -1; + } + nthw_fpga_mgr_delete(p_fpga_mgr); p_fpga_mgr = NULL; } diff --git a/drivers/net/ntnic/nthw/core/nthw_hif.c b/drivers/net/ntnic/nthw/core/nthw_hif.c index f05e1a0c51..cc2aaf83e4 100644 --- a/drivers/net/ntnic/nthw/core/nthw_hif.c +++ b/drivers/net/ntnic/nthw/core/nthw_hif.c @@ -83,23 +83,11 @@ int nthw_hif_init(nthw_hif_t *p, nthw_fpga_t *p_fpga, int n_instance) p->mn_instance, p->mn_fpga_hif_ref_clk_freq, p->mn_fpga_param_hif_per_ps); p->mp_reg_build_seed = NULL; /* Reg/Fld not present on HIF */ - - if (p->mp_reg_build_seed) - p->mp_fld_build_seed = NULL; /* Reg/Fld not present on HIF */ - else - p->mp_fld_build_seed = NULL; + p->mp_fld_build_seed = NULL; /* Reg/Fld not present on HIF */ p->mp_reg_core_speed = NULL; /* Reg/Fld not present on HIF */ - - if (p->mp_reg_core_speed) { - p->mp_fld_core_speed = NULL; /* Reg/Fld not present on HIF */ - p->mp_fld_ddr3_speed = NULL; /* Reg/Fld not present on HIF */ - - } else { - p->mp_reg_core_speed = NULL; - p->mp_fld_core_speed = NULL; - p->mp_fld_ddr3_speed = NULL; - } + p->mp_fld_core_speed = NULL; /* Reg/Fld not present on HIF */ + p->mp_fld_ddr3_speed = NULL; /* Reg/Fld not present on HIF */ /* Optional registers since: 2018-04-25 */ p->mp_reg_int_mask = NULL; /* Reg/Fld not present on HIF */ diff --git a/drivers/net/ntnic/nthw/model/nthw_fpga_model.c b/drivers/net/ntnic/nthw/model/nthw_fpga_model.c index f8e6da2d7f..14d1ebf5fa 100644 --- a/drivers/net/ntnic/nthw/model/nthw_fpga_model.c +++ b/drivers/net/ntnic/nthw/model/nthw_fpga_model.c @@ -28,7 +28,7 @@ static const char *const sa_nthw_fpga_bus_type_str[] = { static const char *get_bus_name(int n_bus_type_id) { - if (n_bus_type_id >= 1 && n_bus_type_id <= (int)ARRAY_SIZE(sa_nthw_fpga_bus_type_str)) + if (n_bus_type_id >= 0 && n_bus_type_id < (int)ARRAY_SIZE(sa_nthw_fpga_bus_type_str)) return sa_nthw_fpga_bus_type_str[n_bus_type_id]; return "ERR"; @@ -678,45 +678,51 @@ void nthw_register_set_debug_mode(nthw_register_t *p, unsigned int debug_mode) static int nthw_register_read_data(const nthw_register_t *p) { int rc = -1; + if (p) { + if (p->mp_owner) { + const int n_bus_type_id = nthw_module_get_bus(p->mp_owner); + const uint32_t addr = p->mn_addr; + const uint32_t len = p->mn_len; + uint32_t *const p_data = p->mp_shadow; + const bool trc = (p->mn_debug_mode & NTHW_REG_TRACE_ON_READ); - const int n_bus_type_id = nthw_module_get_bus(p->mp_owner); - const uint32_t addr = p->mn_addr; - const uint32_t len = p->mn_len; - uint32_t *const p_data = p->mp_shadow; - const bool trc = (p->mn_debug_mode & NTHW_REG_TRACE_ON_READ); + struct fpga_info_s *p_fpga_info = NULL; - struct fpga_info_s *p_fpga_info = NULL; + if (p->mp_owner->mp_owner) + p_fpga_info = p->mp_owner->mp_owner->p_fpga_info; - if (p && p->mp_owner && p->mp_owner->mp_owner) - p_fpga_info = p->mp_owner->mp_owner->p_fpga_info; + assert(p_fpga_info); + assert(p_data); - assert(p_fpga_info); - assert(p_data); - - rc = nthw_read_data(p_fpga_info, trc, n_bus_type_id, addr, len, p_data); + rc = nthw_read_data(p_fpga_info, trc, n_bus_type_id, addr, len, p_data); + } + } return rc; } static int nthw_register_write_data(const nthw_register_t *p, uint32_t cnt) { int rc = -1; + if (p) { + if (p->mp_owner) { + const int n_bus_type_id = nthw_module_get_bus(p->mp_owner); + const uint32_t addr = p->mn_addr; + const uint32_t len = p->mn_len; + uint32_t *const p_data = p->mp_shadow; + const bool trc = (p->mn_debug_mode & NTHW_REG_TRACE_ON_WRITE); - const int n_bus_type_id = nthw_module_get_bus(p->mp_owner); - const uint32_t addr = p->mn_addr; - const uint32_t len = p->mn_len; - uint32_t *const p_data = p->mp_shadow; - const bool trc = (p->mn_debug_mode & NTHW_REG_TRACE_ON_WRITE); + struct fpga_info_s *p_fpga_info = NULL; - struct fpga_info_s *p_fpga_info = NULL; + if (p->mp_owner->mp_owner) + p_fpga_info = p->mp_owner->mp_owner->p_fpga_info; - if (p && p->mp_owner && p->mp_owner->mp_owner) - p_fpga_info = p->mp_owner->mp_owner->p_fpga_info; - - assert(p_fpga_info); - assert(p_data); - - rc = nthw_write_data(p_fpga_info, trc, n_bus_type_id, addr, (len * cnt), p_data); + assert(p_fpga_info); + assert(p_data); + rc = nthw_write_data(p_fpga_info, trc, n_bus_type_id, addr, (len * cnt), + p_data); + } + } return rc; } diff --git a/drivers/net/ntnic/ntnic_ethdev.c b/drivers/net/ntnic/ntnic_ethdev.c index 8568798ec8..f351469d0a 100644 --- a/drivers/net/ntnic/ntnic_ethdev.c +++ b/drivers/net/ntnic/ntnic_ethdev.c @@ -42,7 +42,7 @@ static struct drv_s *_g_p_drv[NUM_ADAPTER_MAX] = { NULL }; static void store_pdrv(struct drv_s *p_drv) { - if (p_drv->adapter_no > NUM_ADAPTER_MAX) { + if (p_drv->adapter_no >= NUM_ADAPTER_MAX) { NT_LOG(ERR, NTNIC, "Internal error adapter number %u out of range. Max number of adapters: %u\n", p_drv->adapter_no, NUM_ADAPTER_MAX); @@ -384,16 +384,17 @@ eth_dev_close(struct rte_eth_dev *eth_dev) internals->p_drv = NULL; rte_eth_dev_release_port(eth_dev); + if (p_drv) { + /* decrease initialized ethernet devices */ + p_drv->n_eth_dev_init_count--; - /* decrease initialized ethernet devices */ - p_drv->n_eth_dev_init_count--; - - /* - * rte_pci_dev has no private member for p_drv - * wait until all rte_eth_dev's are closed - then close adapters via p_drv - */ - if (!p_drv->n_eth_dev_init_count && p_drv) - drv_deinit(p_drv); + /* + * rte_pci_dev has no private member for p_drv + * wait until all rte_eth_dev's are closed - then close adapters via p_drv + */ + if (!p_drv->n_eth_dev_init_count) + drv_deinit(p_drv); + } return 0; } diff --git a/drivers/net/ntnic/ntnic_vfio.c b/drivers/net/ntnic/ntnic_vfio.c index f4433152b7..0542b1ce62 100644 --- a/drivers/net/ntnic/ntnic_vfio.c +++ b/drivers/net/ntnic/ntnic_vfio.c @@ -49,6 +49,7 @@ vfio_get(int vf_num) int nt_vfio_setup(struct rte_pci_device *dev) { + int ret; char devname[RTE_DEV_NAME_MAX_LEN] = { 0 }; int iommu_group_num; int vf_num; @@ -71,7 +72,9 @@ nt_vfio_setup(struct rte_pci_device *dev) vfio->iova_addr = START_VF_IOVA; rte_pci_device_name(&dev->addr, devname, RTE_DEV_NAME_MAX_LEN); - rte_vfio_get_group_num(rte_pci_get_sysfs_path(), devname, &iommu_group_num); + ret = rte_vfio_get_group_num(rte_pci_get_sysfs_path(), devname, &iommu_group_num); + if (ret <= 0) + return -1; if (vf_num == 0) { /* use default container for pf0 */ diff --git a/drivers/net/ntnic/ntutil/nt_util.c b/drivers/net/ntnic/ntutil/nt_util.c index 9904e3df3b..a69a8e10c1 100644 --- a/drivers/net/ntnic/ntutil/nt_util.c +++ b/drivers/net/ntnic/ntutil/nt_util.c @@ -31,7 +31,8 @@ uint64_t nt_os_get_time_monotonic_counter(void) /* Allocation size matching minimum alignment of specified size */ uint64_t nt_util_align_size(uint64_t size) { - return 1 << rte_log2_u64(size); + uint64_t alignment_size = 1ULL << rte_log2_u64(size); + return alignment_size; } void nt_util_vfio_init(struct nt_util_vfio_impl *impl) -- 2.45.0