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 20F9D45BB0; Wed, 23 Oct 2024 14:02:18 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8EDF942E4B; Wed, 23 Oct 2024 14:00:29 +0200 (CEST) Received: from inva021.nxp.com (inva021.nxp.com [92.121.34.21]) by mails.dpdk.org (Postfix) with ESMTP id C89B840ED3; Wed, 23 Oct 2024 14:00:05 +0200 (CEST) Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id A247B2025B2; Wed, 23 Oct 2024 14:00:05 +0200 (CEST) Received: from aprdc01srsp001v.ap-rdc01.nxp.com (aprdc01srsp001v.ap-rdc01.nxp.com [165.114.16.16]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 6FD732025A8; Wed, 23 Oct 2024 14:00:05 +0200 (CEST) Received: from lsv03379.swis.in-blr01.nxp.com (lsv03379.swis.in-blr01.nxp.com [92.120.147.188]) by aprdc01srsp001v.ap-rdc01.nxp.com (Postfix) with ESMTP id 9475E183DC02; Wed, 23 Oct 2024 20:00:04 +0800 (+08) From: vanshika.shukla@nxp.com To: dev@dpdk.org, Hemant Agrawal , Sachin Saxena , Nipun Gupta , Roy Pledge , Youri Querry Cc: stable@dpdk.org, Rohit Raj Subject: [v5 19/42] bus/fslmc: fix coverity issue Date: Wed, 23 Oct 2024 17:29:32 +0530 Message-Id: <20241023115955.1207617-20-vanshika.shukla@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241023115955.1207617-1-vanshika.shukla@nxp.com> References: <20241022191256.516818-1-vanshika.shukla@nxp.com> <20241023115955.1207617-1-vanshika.shukla@nxp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Virus-Scanned: ClamAV using ClamSMTP 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: Rohit Raj Fix Issues reported by NXP Internal Coverity. Fixes: 64f131a82fbe ("bus/fslmc: add qbman debug") Cc: hemant.agrawal@nxp.com Cc: stable@dpdk.org Signed-off-by: Rohit Raj --- drivers/bus/fslmc/qbman/qbman_debug.c | 49 +++++++++++++++++---------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/drivers/bus/fslmc/qbman/qbman_debug.c b/drivers/bus/fslmc/qbman/qbman_debug.c index eea06988ff..0e471ec3fd 100644 --- a/drivers/bus/fslmc/qbman/qbman_debug.c +++ b/drivers/bus/fslmc/qbman/qbman_debug.c @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: BSD-3-Clause * Copyright (C) 2015 Freescale Semiconductor, Inc. - * Copyright 2018-2020 NXP + * Copyright 2018-2020,2022 NXP */ #include "compat.h" @@ -37,6 +37,7 @@ int qbman_bp_query(struct qbman_swp *s, uint32_t bpid, struct qbman_bp_query_rslt *r) { struct qbman_bp_query_desc *p; + struct qbman_bp_query_rslt *bp_query_rslt; /* Start the management command */ p = (struct qbman_bp_query_desc *)qbman_swp_mc_start(s); @@ -47,14 +48,16 @@ int qbman_bp_query(struct qbman_swp *s, uint32_t bpid, p->bpid = bpid; /* Complete the management command */ - *r = *(struct qbman_bp_query_rslt *)qbman_swp_mc_complete(s, p, - QBMAN_BP_QUERY); - if (!r) { + bp_query_rslt = (struct qbman_bp_query_rslt *)qbman_swp_mc_complete(s, + p, QBMAN_BP_QUERY); + if (!bp_query_rslt) { pr_err("qbman: Query BPID %d failed, no response\n", bpid); return -EIO; } + *r = *bp_query_rslt; + /* Decode the outcome */ QBMAN_BUG_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_BP_QUERY); @@ -202,20 +205,23 @@ int qbman_fq_query(struct qbman_swp *s, uint32_t fqid, struct qbman_fq_query_rslt *r) { struct qbman_fq_query_desc *p; + struct qbman_fq_query_rslt *fq_query_rslt; p = (struct qbman_fq_query_desc *)qbman_swp_mc_start(s); if (!p) return -EBUSY; p->fqid = fqid; - *r = *(struct qbman_fq_query_rslt *)qbman_swp_mc_complete(s, p, - QBMAN_FQ_QUERY); - if (!r) { + fq_query_rslt = (struct qbman_fq_query_rslt *)qbman_swp_mc_complete(s, + p, QBMAN_FQ_QUERY); + if (!fq_query_rslt) { pr_err("qbman: Query FQID %d failed, no response\n", fqid); return -EIO; } + *r = *fq_query_rslt; + /* Decode the outcome */ QBMAN_BUG_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_FQ_QUERY); @@ -398,20 +404,23 @@ int qbman_cgr_query(struct qbman_swp *s, uint32_t cgid, struct qbman_cgr_query_rslt *r) { struct qbman_cgr_query_desc *p; + struct qbman_cgr_query_rslt *cgr_query_rslt; p = (struct qbman_cgr_query_desc *)qbman_swp_mc_start(s); if (!p) return -EBUSY; p->cgid = cgid; - *r = *(struct qbman_cgr_query_rslt *)qbman_swp_mc_complete(s, p, - QBMAN_CGR_QUERY); - if (!r) { + cgr_query_rslt = (struct qbman_cgr_query_rslt *)qbman_swp_mc_complete(s, + p, QBMAN_CGR_QUERY); + if (!cgr_query_rslt) { pr_err("qbman: Query CGID %d failed, no response\n", cgid); return -EIO; } + *r = *cgr_query_rslt; + /* Decode the outcome */ QBMAN_BUG_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_CGR_QUERY); @@ -473,20 +482,23 @@ int qbman_cgr_wred_query(struct qbman_swp *s, uint32_t cgid, struct qbman_wred_query_rslt *r) { struct qbman_cgr_query_desc *p; + struct qbman_wred_query_rslt *wred_query_rslt; p = (struct qbman_cgr_query_desc *)qbman_swp_mc_start(s); if (!p) return -EBUSY; p->cgid = cgid; - *r = *(struct qbman_wred_query_rslt *)qbman_swp_mc_complete(s, p, - QBMAN_WRED_QUERY); - if (!r) { + wred_query_rslt = (struct qbman_wred_query_rslt *)qbman_swp_mc_complete( + s, p, QBMAN_WRED_QUERY); + if (!wred_query_rslt) { pr_err("qbman: Query CGID WRED %d failed, no response\n", cgid); return -EIO; } + *r = *wred_query_rslt; + /* Decode the outcome */ QBMAN_BUG_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_WRED_QUERY); @@ -527,7 +539,7 @@ void qbman_cgr_attr_wred_dp_decompose(uint32_t dp, uint64_t *minth, if (mn == 0) *maxth = ma; else - *maxth = ((ma+256) * (1<<(mn-1))); + *maxth = ((uint64_t)(ma+256) * (1<<(mn-1))); if (step_s == 0) *minth = *maxth - step_i; @@ -630,6 +642,7 @@ int qbman_wqchan_query(struct qbman_swp *s, uint16_t chanid, struct qbman_wqchan_query_rslt *r) { struct qbman_wqchan_query_desc *p; + struct qbman_wqchan_query_rslt *wqchan_query_rslt; /* Start the management command */ p = (struct qbman_wqchan_query_desc *)qbman_swp_mc_start(s); @@ -640,14 +653,16 @@ int qbman_wqchan_query(struct qbman_swp *s, uint16_t chanid, p->chid = chanid; /* Complete the management command */ - *r = *(struct qbman_wqchan_query_rslt *)qbman_swp_mc_complete(s, p, - QBMAN_WQ_QUERY); - if (!r) { + wqchan_query_rslt = (struct qbman_wqchan_query_rslt *)qbman_swp_mc_complete( + s, p, QBMAN_WQ_QUERY); + if (!wqchan_query_rslt) { pr_err("qbman: Query WQ Channel %d failed, no response\n", chanid); return -EIO; } + *r = *wqchan_query_rslt; + /* Decode the outcome */ QBMAN_BUG_ON((r->verb & QBMAN_RESPONSE_VERB_MASK) != QBMAN_WQ_QUERY); -- 2.25.1