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 0B2EC45AAF; Fri, 4 Oct 2024 17:08:06 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8341342708; Fri, 4 Oct 2024 17:08:05 +0200 (CEST) Received: from egress-ip11a.ess.de.barracuda.com (egress-ip11a.ess.de.barracuda.com [18.184.203.234]) by mails.dpdk.org (Postfix) with ESMTP id 890FF410FC for ; Fri, 4 Oct 2024 17:08:02 +0200 (CEST) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02lp2241.outbound.protection.outlook.com [104.47.11.241]) by mx-outbound8-201.eu-central-1a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 04 Oct 2024 15:08:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vzpgHz367/FqZkBOD04D5GKloCXFCz1L8z19E5YnvmF0PJgUfZbqHF2h1GfoFanpm+RZGon/FTIDICWnD1RAjNhwp6MkdwX7zPB6YFHyxwoaQ3D1Pgfsd8i0KqOztg8w5q4MLb+1zni5ENFkr8XcljiYX4EQjNNYgTaBiI2UjsgIGL0ee9hgze8D8CC74cDV6Do17HCSDeA+aOo8r+SMbH/vhJAhiMiEOdyY8Tcwn2L0NpgI2zCh+quhRVx1i6usb7JLXqd8R4snekA5CsvpZq6MhJMnWBy0/lOaUPyXVCWJ1noumEIKr17KuInSctV/EsoqzC/LdheLRQ+IcmLxZA== 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=zGmpqLFthQZFiyGwuQyK+MyRB+KzyyTFX1etQ4YwQvO+1c8Pj60LM4kUfk5Bya0fWgRKx44vA2a07PazeeX+zFC8XSJU+4jePBmk2/AohuM2daHrt7k+6as0dHoaoSzfdqWXY/vlLE9ZN5YS32WPXSpviA1elb5s+0S5Ge8DTDmynvE+HUOAMJ5CPCCe4ZXpnwbHwfsuPPgB4bNa4OLE+M3rjrYPIFlEbUYrW77VXFEvVPlr3LBVAi2i9qdodSivRSoAyvEok/X8Dtf6Nx7GkKAHK1OZcmkk0MPN5AfmVOOuBdN+05c41jy2BpCthu+yL9r2s2KHE5z/bBUqTpJs+A== 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=DoQa9Xt6x00OKUln9xPKqbp7JLho7x5lkDh6mb1B9SjZJCBW9msMvtgi52v0CTNttwD40bvRXgN1f7mqzrgbOpsQgM5pOI+mzhn5vk6pNijZV+Ysf4wJcBDvNg0Q+55DORLF0N9UtH4RAG+qefui0ottRP0yfbxWG2q2xMkgPwQ= Received: from AM0PR02CA0012.eurprd02.prod.outlook.com (2603:10a6:208:3e::25) by AM8P190MB0963.EURP190.PROD.OUTLOOK.COM (2603:10a6:20b:1c6::7) 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:07:59 +0000 Received: from AMS0EPF000001AC.eurprd05.prod.outlook.com (2603:10a6:208:3e:cafe::a3) by AM0PR02CA0012.outlook.office365.com (2603:10a6:208:3e::25) 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:07:59 +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 AMS0EPF000001AC.mail.protection.outlook.com (10.167.16.152) with Microsoft SMTP Server id 15.20.7918.13 via Frontend Transport; Fri, 4 Oct 2024 15:07:59 +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:06:49 +0200 Message-ID: <20241004150749.261020-3-sil-plv@napatech.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20241004150749.261020-1-sil-plv@napatech.com> References: <20241004150749.261020-1-sil-plv@napatech.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS0EPF000001AC:EE_|AM8P190MB0963:EE_ Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: 339c0f38-df83-404a-3df5-08dce48655e6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?hHSetY1+IxaYnJ30IFjpkUwb26HrtmepE71extikM5eHLRhXyr3mcSZivjll?= =?us-ascii?Q?CY4/Q7+XTFHvIV3pWnQ9JESYf02kFB98y7FXI0xXJoNh4R8xzqiJFzIL7ajz?= =?us-ascii?Q?05TwWffGJwksP0mZE1TZkh1t0IwJ1X4doQi8bt142BrJgZnNt1aLnJfMng0W?= =?us-ascii?Q?z1Qx4fdUvvMXsUxswtkb8bT0Gp9R5T1lYhkuSKQrzrwJPoOT+CZ9c4MkMMCe?= =?us-ascii?Q?Uwmxxbv86mX4P5Nx9dn565AA0DH7NcLQtCX2hnfkf38hXWGbmsUPH0sIRFpp?= =?us-ascii?Q?BbGwUF/4Hz6IPtMeX54Q6zpm9NcaRcu5ayFq3OYfgeGb1g8Mi6D/IYbSNsbC?= =?us-ascii?Q?PwyZczB7V6gcw9b/hn21uemASTYjL4yFc+rHM3zzRB0jwgOBM5fTKeByOzpT?= =?us-ascii?Q?RxOd1gdrqpFzf/fLH5ZIdniKLNq+DVzC5zDslKPplXZZz87+r+R8EC10XKDt?= =?us-ascii?Q?w4PXIstdD29KJywwl8Gq0UFxo57hY3Z9l/kjiGrHt0vFMgCPMR+utUT7jtgn?= =?us-ascii?Q?MGfebseHKOUpJP//dUxiBefSmrq4RfU2mJla/h3irbgFnYY9lkbsRnoaimv/?= =?us-ascii?Q?lvGf48r8VUQS88xtGJYodzuPNMUh4atkCS3XznAUGJKBz18yQVhxkigRr+YS?= =?us-ascii?Q?5Kv4Y+K5LutYqw5hmzRj1WBzd/15+L0ug6frEgGsfTlofYHDHU6tz4XIzCGs?= =?us-ascii?Q?ECmGIq7OzJeQhCyib7kV1iDFrbraXn9YE48Dna9gX/1QfVltmyqnb/3LJwic?= =?us-ascii?Q?UIG1aDoOyHt82lEbLuyZ2BZCrmBnEshC649p2196Q3VUuLPoAmAdKI00Vgd2?= =?us-ascii?Q?YuauQ6FHkmTfHazRAqVOfT5qB3nY7uecA4InsOch8z2T+OL+SziundQ7Iuj9?= =?us-ascii?Q?3XRQUAX2lqcxxxWuuValeA3vBdSZCXlZnt84ivGWFnmy30DSjxPLAkqFfKdj?= =?us-ascii?Q?zkrQgUyjchWPGhQR7qvF+y8EGOAr/2R8Obck+sG3dRgVoraB7BzyidoNDYz0?= =?us-ascii?Q?V3bP9A6f698a5VWnK3ACQyomhJ51Oawv5t11hEeP59qI4bUmXDMOXIrihybv?= =?us-ascii?Q?nUJ8rYhj15Sa6Bu1Kb0m1Ry8cyd9JziMs7rhUIYQ7vEM/xAUi30VNHgN0h2n?= =?us-ascii?Q?WWmMHikXB0a9I9Xa/Wv2gjr5LnGhUigcWmynKmKXzJnpTRD6OlfmFKrMAquZ?= =?us-ascii?Q?H1gVvWLLe0VMfKuQ+bRsPW0wYFrwiR1YRkZFtVJvo7iSp6q4WBVrkgcUKV9H?= =?us-ascii?Q?1ZG+Qs6egh2UkzUplsjK83uAALo+T6DMliI8zl6nQan7JlNWbyMc/BxROZiA?= =?us-ascii?Q?s+y58ijfH2sB2KL+94mtngSTBJhbkuRBVWQ/xYQrHtrKIzXb/e/gKesko0dG?= =?us-ascii?Q?73zUcqp3hLNvRqhnc5pmkUtYLjjq?= 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)(1800799024)(376014)(36860700013)(82310400026); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 0NnOkhHmGWpqZ48ory+52p/iG0QZtWC3bj14/4xbth97Qxpbgtp2YHW//AX3txR1pvH0PMK6LOzOmApQOMgYKGh2PEY/pOxV6NpkSd3ktoM2yeMA5//gI4u/QBG+3I3CW2Cvb8xCosiGULUAkMXo2STmaxhcS/g2VxLhXDqHNatj+e8J3cEqa8XdMUJiBaHrJYNv3ailgnyklmD/8cHlAqYVaOUzoHMaHfyZmAQisvz6lHK3XnXpEmyAqxUNJoZZMOm2Jn3z6LK3ZHZUP9axMnOjBpfkRZ+hr0zrD6W7ZjuBTYphmqtzcOUgaft184y92oaxYcKbU2ZL+SkhVcQ3Ojauc5RURWktnjSydkb7ylfvc7ebYT5LlYeSjfMJ3yxSIyyto4Um6fJDCWjDpJXcW+bxnuQhx3d5Mw1mVRKBSh98BDZFLkkXnFTj1Z1ZQ9vSgKSluzNQSOOPKyzyGJ4YVeiJ+sCA4cVZDi0cDNyQ4JXjwcUm4G9vLv0trE3xo09NUoywVEP5HTFlFHMjo2Tk3RsFejYDgP3QJVtngAh51uJkQHBgV4JVNgEGned7XMk2iWuIcbtAA/WoF4+7VlS/Of66qfNwDISx9ZHMnID4/mSqzJV5VYV1saZ9pGxS4ibl6tXGp4BwMRoQYw0dZrGWjA== X-OriginatorOrg: napatech.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2024 15:07:59.5639 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 339c0f38-df83-404a-3df5-08dce48655e6 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: AMS0EPF000001AC.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8P190MB0963 X-BESS-ID: 1728054481-302249-12638-31653-1 X-BESS-VER: 2019.1_20240924.1654 X-BESS-Apparent-Source-IP: 104.47.11.241 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 cloudscan21-44.eu-central-1b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE_7582B META: Custom Rule 7582B 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS113687 scores of KILL_LEVEL=7.0 tests=BSF_RULE_7582B, BSF_BESS_OUTBOUND 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