[1/2] net/nfp: fix checking return value

Message ID 20231010061727.205886-2-chaoyong.he@corigine.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series Fix two converity issue of NFP PMD |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chaoyong He Oct. 10, 2023, 6:17 a.m. UTC
  From: Long Wu <long.wu@corigine.com>

CI found that calling "rte_pci_write_config" without
checking return value.

Coverity issue: 403100
Fixes: 1fbe51cd9c3a ("net/nfp: extend usage of BAR from 8 to 24")
Cc: chaoyong.he@corigine.com
Cc: stable@dpdk.org

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/nfpcore/nfp6000_pcie.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
  

Patch

diff --git a/drivers/net/nfp/nfpcore/nfp6000_pcie.c b/drivers/net/nfp/nfpcore/nfp6000_pcie.c
index 13cf523506..a6fd89b6c8 100644
--- a/drivers/net/nfp/nfpcore/nfp6000_pcie.c
+++ b/drivers/net/nfp/nfpcore/nfp6000_pcie.c
@@ -214,8 +214,9 @@  nfp_bar_write(struct nfp_pcie_user *nfp,
 		rte_read32(nfp->csr + xbar);
 	} else {
 		xbar += nfp->dev_info->pcie_cfg_expbar_offset;
-		rte_pci_write_config(nfp->pci_dev, &newcfg, sizeof(uint32_t),
-				xbar);
+		if (rte_pci_write_config(nfp->pci_dev, &newcfg, sizeof(uint32_t),
+				xbar) < 0)
+			return -EIO;
 	}
 
 	bar->barcfg = newcfg;
@@ -379,7 +380,8 @@  nfp_enable_bars(struct nfp_pcie_user *nfp)
 	bar = &nfp->bar[0];
 	bar->lock = true;
 
-	nfp_bar_write(nfp, bar, barcfg_msix_general);
+	if (nfp_bar_write(nfp, bar, barcfg_msix_general) < 0)
+		return -EIO;
 
 	/* Sort bars by bit size - use the smallest possible first. */
 	qsort(&nfp->bar[0], nfp->bars, sizeof(nfp->bar[0]), nfp_cmp_bars);