From patchwork Sat Feb 12 12:38:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 107398 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6A5B4A034E; Sat, 12 Feb 2022 13:38:32 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2C2C740395; Sat, 12 Feb 2022 13:38:32 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 6E6DC40140 for ; Sat, 12 Feb 2022 13:38:30 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 21CCXnJP008111 for ; Sat, 12 Feb 2022 04:38:29 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=9eFVVFhCvbWCuNB5rFIUUbPipZ0eMGZozQSAsLaJhI4=; b=AbCxzMPAOHSXMGWpzXbBYkudPRLCeUp6s7iIZXojGmp0a3S17qmvXmZfiLeEPSK73+36 4mYzGdtVcL4WQZoH4KjUbHoe8zwlPkHQpivr+ji75+H4/SS5WJPfByEXO/vD9Qi9h39c EwIuj2uJCR6qZjzJFx+tyorvHfEOeaiTVwC8H4mkAThXsYzhMzYXHV1ByGx/vVv0pJCP olIYNJYkMtLRdBXdduC3egXYCDDgAMFdXMToardTXXzIjurQgKKgXtMGCEnVCUlskv21 n2uGyK6BGW2qYXf2e+FdQqXLgp/Oz7+j0Elk6X6UPfMRLztzeiaSDIaFqmA/ZCxlOohU NA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3e5y70j8un-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sat, 12 Feb 2022 04:38:29 -0800 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sat, 12 Feb 2022 04:38:27 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.18 via Frontend Transport; Sat, 12 Feb 2022 04:38:27 -0800 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id BD2EC5B6940; Sat, 12 Feb 2022 04:38:25 -0800 (PST) From: Gowrishankar Muthukrishnan To: CC: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , , Gowrishankar Muthukrishnan Subject: [PATCH 1/3] common/cnxk: check return value for error Date: Sat, 12 Feb 2022 18:08:18 +0530 Message-ID: <20220212123820.3394341-1-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: v-9N70T2FordzsQiE3Zh8G34cZA15RvG X-Proofpoint-GUID: v-9N70T2FordzsQiE3Zh8G34cZA15RvG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-12_04,2022-02-11_01,2021-12-02_01 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 This patch fixes coverity issue by adding checks on return values. Coverity issue: 373628, 374858, 370213, 370215 Fixes: af75aac78978 ("common/cnxk: support telemetry for NIX") Fixes: d61138d4f0e ("drivers: remove direct access to interrupt handle") Fixes: fcdef46b669 ("common/cnxk: support NIX TM debug and misc utils") Fixes: df405df95ee ("common/cnxk: add NIX TM helper to alloc/free resource") Signed-off-by: Gowrishankar Muthukrishnan --- drivers/common/cnxk/cnxk_telemetry_nix.c | 3 +++ drivers/common/cnxk/roc_irq.c | 5 ++++- drivers/common/cnxk/roc_nix_debug.c | 4 +++- drivers/common/cnxk/roc_nix_tm.c | 6 ++++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/common/cnxk/cnxk_telemetry_nix.c b/drivers/common/cnxk/cnxk_telemetry_nix.c index df6458039d..4119e9ee4f 100644 --- a/drivers/common/cnxk/cnxk_telemetry_nix.c +++ b/drivers/common/cnxk/cnxk_telemetry_nix.c @@ -765,6 +765,9 @@ cnxk_nix_tel_handle_info_x(const char *cmd, const char *params, plt_strlcpy(buf, params, PCI_PRI_STR_SIZE + 1); name = strtok(buf, ","); + if (name == NULL) + goto exit; + param = strtok(NULL, "\0"); node = nix_tel_node_get_by_pcidev_name(name); diff --git a/drivers/common/cnxk/roc_irq.c b/drivers/common/cnxk/roc_irq.c index 7a24297d72..010b121176 100644 --- a/drivers/common/cnxk/roc_irq.c +++ b/drivers/common/cnxk/roc_irq.c @@ -160,7 +160,10 @@ dev_irq_register(struct plt_intr_handle *intr_handle, plt_intr_callback_fn cb, return rc; } - plt_intr_efds_index_set(intr_handle, vec, fd); + rc = plt_intr_efds_index_set(intr_handle, vec, fd); + if (rc) + return rc; + nb_efd = (vec > (uint32_t)plt_intr_nb_efd_get(intr_handle)) ? vec : (uint32_t)plt_intr_nb_efd_get(intr_handle); plt_intr_nb_efd_set(intr_handle, nb_efd); diff --git a/drivers/common/cnxk/roc_nix_debug.c b/drivers/common/cnxk/roc_nix_debug.c index d5143882f5..1ae045172e 100644 --- a/drivers/common/cnxk/roc_nix_debug.c +++ b/drivers/common/cnxk/roc_nix_debug.c @@ -52,7 +52,9 @@ nix_bitmap_dump(struct plt_bitmap *bmp) int i; plt_bitmap_scan_init(bmp); - plt_bitmap_scan(bmp, &pos, &slab); + if (!plt_bitmap_scan(bmp, &pos, &slab)) + return; + start_pos = pos; nix_dump_no_nl(" \t\t["); diff --git a/drivers/common/cnxk/roc_nix_tm.c b/drivers/common/cnxk/roc_nix_tm.c index a0448bec61..517502b1af 100644 --- a/drivers/common/cnxk/roc_nix_tm.c +++ b/drivers/common/cnxk/roc_nix_tm.c @@ -1016,8 +1016,10 @@ nix_tm_assign_hw_id(struct nix *nix, struct nix_tm_node *parent, return -EFAULT; } - if (!slab) - plt_bitmap_scan(bmp, &pos, &slab); + if (!slab) { + if (!plt_bitmap_scan(bmp, &pos, &slab)) + return -ENOENT; + } if (child->priority == parent->rr_prio && spare_schq != -1) { /* Use spare schq first if present */ From patchwork Sat Feb 12 12:38:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 107399 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2EAE6A034E; Sat, 12 Feb 2022 13:38:37 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1DD9941172; Sat, 12 Feb 2022 13:38:37 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id C8B3C40140 for ; Sat, 12 Feb 2022 13:38:35 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 21CCaZpQ011982 for ; Sat, 12 Feb 2022 04:38:35 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=WCNN/9EpoJMepo5lcvq4Gdrp6tGWKS3eREHguUXwoos=; b=CzvlaNr6KyHuiM8lQEqR2d7ik6fpb6jXSTOax2Yd7EC+pA532+SyIzaxn8p0Emtt27hj 2IJkvHxbddj0qWhCDzOnSbwG7Ksn08R0CkAF+Z48ySBuG9lBfV31BGhrA5jlkT90FxEv 5lunN0o4dWlt/ZdOn72ynfyDIrPYNsp3XyZG+e/7RukDzKFqU5ASOeYXMofj+nNF/g65 pHFGA89ABw9YIXtS1coRwvOXzY6/IztlyKOEw31q5ktnWZ46HnTvb+CPkWN2pRgeE2PE DapSni2GMzuHY8CnaO9E2LLtpnVikxuK1ieFn0NcCEurI7KAph+8aXA/BlveosHNiOTw Qw== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3e5y70j8uv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sat, 12 Feb 2022 04:38:35 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sat, 12 Feb 2022 04:38:33 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 12 Feb 2022 04:38:32 -0800 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id D171B5B6940; Sat, 12 Feb 2022 04:38:30 -0800 (PST) From: Gowrishankar Muthukrishnan To: CC: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , , Gowrishankar Muthukrishnan Subject: [PATCH 2/3] common/cnx: fix unintended sign extension Date: Sat, 12 Feb 2022 18:08:19 +0530 Message-ID: <20220212123820.3394341-2-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220212123820.3394341-1-gmuthukrishn@marvell.com> References: <20220212123820.3394341-1-gmuthukrishn@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: rz3Ti9t4W04IeUf6vY1Jz7YjT1e8UR1V X-Proofpoint-GUID: rz3Ti9t4W04IeUf6vY1Jz7YjT1e8UR1V X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-12_04,2022-02-11_01,2021-12-02_01 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 This patch fixes unintended sign extensions reported in coverity scan. Fixes: 8ca851cdc59 ("common/cnxk: support dual VLAN insert and strip actions") Coverity issue: 373258 Signed-off-by: Gowrishankar Muthukrishnan --- drivers/common/cnxk/roc_npc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/common/cnxk/roc_npc.c b/drivers/common/cnxk/roc_npc.c index e3961bfbc6..453fd5d3e0 100644 --- a/drivers/common/cnxk/roc_npc.c +++ b/drivers/common/cnxk/roc_npc.c @@ -969,14 +969,14 @@ npc_vtag_insert_action_configure(struct mbox *mbox, struct roc_npc_flow *flow, vtag_cfg->cfg_type = VTAG_TX; vtag_cfg->vtag_size = NIX_VTAGSIZE_T4; vtag_cfg->tx.vtag0 = - ((vlan_info[0].vlan_ethtype << 16) | + (((uint32_t)vlan_info[0].vlan_ethtype << 16) | (vlan_info[0].vlan_pcp << 13) | vlan_info[0].vlan_id); vtag_cfg->tx.cfg_vtag0 = 1; if (flow->vtag_insert_count == 2) { vtag_cfg->tx.vtag1 = - ((vlan_info[1].vlan_ethtype << 16) | + (((uint32_t)vlan_info[1].vlan_ethtype << 16) | (vlan_info[1].vlan_pcp << 13) | vlan_info[1].vlan_id); vtag_cfg->tx.cfg_vtag1 = 1; From patchwork Sat Feb 12 12:38:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gowrishankar Muthukrishnan X-Patchwork-Id: 107400 X-Patchwork-Delegate: jerinj@marvell.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 248A0A034E; Sat, 12 Feb 2022 13:38:42 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 127294117D; Sat, 12 Feb 2022 13:38:40 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 09CC44118F for ; Sat, 12 Feb 2022 13:38:37 +0100 (CET) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 21CBs89r000545 for ; Sat, 12 Feb 2022 04:38:37 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=tv/E1QmIKfqJsX1bgMK267vb+dxGEy3RJok1oTQiOKo=; b=PWMY1YbCVKxcdyo2RzpJdShsRSaEGowLf622UhFeWwxa8Qa+CPw0Eh8h5x+jQlGQ2Rbx x2qA5utzCfNWDL29FcOauMGRhJ7apDd/vbbZpHUakS5cziHBGasTeKz1Ba2gIxm50XNe /7qHAvm46IKS5STCcdv3Pu4xRmJNPvV9+hdKda5LC28MNeKaU8ywWUneLjB1PvHYgFmu vHw7rm/4xkshs5pCDSZsjSGIUttvyPjVOTegA3Mii9dr6DmYwd/XGlrexCbkn9sXv2FA A9KmouVMdjIv0+Yxa0TLgzJEUrxmY3w8HgZnOoJKIPdmJbuuT3I2vDCww3xNLAz5v4vo JQ== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3e6b4rr8jk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Sat, 12 Feb 2022 04:38:37 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Sat, 12 Feb 2022 04:38:35 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Sat, 12 Feb 2022 04:38:35 -0800 Received: from localhost.localdomain (unknown [10.28.34.38]) by maili.marvell.com (Postfix) with ESMTP id 78B625B6941; Sat, 12 Feb 2022 04:38:33 -0800 (PST) From: Gowrishankar Muthukrishnan To: CC: Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , , Gowrishankar Muthukrishnan Subject: [PATCH 3/3] common/cnxk: fix uninitialized pointer read Date: Sat, 12 Feb 2022 18:08:20 +0530 Message-ID: <20220212123820.3394341-3-gmuthukrishn@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220212123820.3394341-1-gmuthukrishn@marvell.com> References: <20220212123820.3394341-1-gmuthukrishn@marvell.com> MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: dSRZMdimqehxesvW9Dwo5b09Z7FPPPnk X-Proofpoint-GUID: dSRZMdimqehxesvW9Dwo5b09Z7FPPPnk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.816,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2022-02-12_04,2022-02-11_01,2021-12-02_01 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 Fix uninitialized pointer read reported in coverity scan. Fixes: c34ea71b878 ("common/cnxk: add NPC parsing API") Coverity issue: 370214, 370217, 370219, 370220, 370221, 370223, 370224, 370225, 372065 Signed-off-by: Gowrishankar Muthukrishnan --- drivers/common/cnxk/roc_npc_parse.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/common/cnxk/roc_npc_parse.c b/drivers/common/cnxk/roc_npc_parse.c index 1f21693369..41ff0fcc6b 100644 --- a/drivers/common/cnxk/roc_npc_parse.c +++ b/drivers/common/cnxk/roc_npc_parse.c @@ -112,6 +112,7 @@ npc_parse_cpt_hdr(struct npc_parse_state *pst) info.hw_hdr_len = 0; /* Prepare for parsing the item */ + info.def_mask = NULL; info.hw_mask = &hw_mask; info.len = pst->pattern->size; npc_get_hw_supp_mask(pst, &info, lid, lt); @@ -149,6 +150,7 @@ npc_parse_higig2_hdr(struct npc_parse_state *pst) } /* Prepare for parsing the item */ + info.def_mask = NULL; info.hw_mask = &hw_mask; info.len = pst->pattern->size; npc_get_hw_supp_mask(pst, &info, lid, lt); @@ -198,6 +200,7 @@ npc_parse_la(struct npc_parse_state *pst) } /* Prepare for parsing the item */ + info.def_mask = NULL; info.hw_mask = &hw_mask; info.len = sizeof(eth_item->hdr); npc_get_hw_supp_mask(pst, &info, lid, lt); @@ -236,6 +239,7 @@ npc_parse_lb(struct npc_parse_state *pst) int nr_vlans = 0; int rc; + info.def_mask = NULL; info.spec = NULL; info.mask = NULL; info.def_mask = NULL; @@ -396,12 +400,12 @@ npc_parse_mpls_label_stack(struct npc_parse_state *pst, int *flag) * pst->pattern points to first MPLS label. We only check * that subsequent labels do not have anything to match. */ + info.def_mask = NULL; info.hw_mask = NULL; info.len = pattern->size; info.spec = NULL; info.mask = NULL; info.hw_hdr_len = 0; - info.def_mask = NULL; while (pattern->type == ROC_NPC_ITEM_TYPE_MPLS) { nr_labels++; @@ -447,6 +451,7 @@ npc_parse_mpls(struct npc_parse_state *pst, int lid) info.len = pst->pattern->size; info.spec = NULL; info.mask = NULL; + info.def_mask = NULL; info.hw_hdr_len = 0; npc_get_hw_supp_mask(pst, &info, lid, lt); @@ -547,6 +552,7 @@ npc_parse_lc(struct npc_parse_state *pst) if (pst->pattern->type == ROC_NPC_ITEM_TYPE_MPLS) return npc_parse_mpls(pst, NPC_LID_LC); + info.def_mask = NULL; info.hw_mask = &hw_mask; info.spec = NULL; info.mask = NULL; @@ -638,10 +644,10 @@ npc_parse_ld(struct npc_parse_state *pst) return npc_parse_mpls(pst, NPC_LID_LD); return 0; } + info.def_mask = NULL; info.hw_mask = &hw_mask; info.spec = NULL; info.mask = NULL; - info.def_mask = NULL; info.len = 0; info.hw_hdr_len = 0; @@ -797,6 +803,7 @@ npc_parse_lf(struct npc_parse_state *pst) lflags = 0; /* No match support for vlan tags */ + info.def_mask = NULL; info.hw_mask = NULL; info.len = pst->pattern->size; info.spec = NULL; @@ -855,6 +862,7 @@ npc_parse_lg(struct npc_parse_state *pst) if (!pst->tunnel) return 0; + info.def_mask = NULL; info.hw_mask = &hw_mask; info.spec = NULL; info.mask = NULL; @@ -891,6 +899,7 @@ npc_parse_lh(struct npc_parse_state *pst) if (!pst->tunnel) return 0; + info.def_mask = NULL; info.hw_mask = &hw_mask; info.spec = NULL; info.mask = NULL;