[dpdk-dev,01/13] net/bnxt: check return values in bnxt_dev_init

Message ID 20180108202437.56305-2-ajit.khaparde@broadcom.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ajit Khaparde Jan. 8, 2018, 8:24 p.m. UTC
  We are not checking for return values of functions like
bnxt_hwrm_queue_qportcfg and bnxt_hwrm_func_qcfg in bnxt_dev_init
thereby preventing a cleanup in case of a HWRM command failure.
This patch fixes that.

Signed-off-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_ethdev.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
  

Comments

Stephen Hemminger Jan. 8, 2018, 8:53 p.m. UTC | #1
On Mon,  8 Jan 2018 12:24:25 -0800
Ajit Khaparde <ajit.khaparde@broadcom.com> wrote:

> +	rc = bnxt_hwrm_queue_qportcfg(bp);
> +	if (rc) {
> +		RTE_LOG(ERR, PMD, "hwrm queue qportcfg failed\n");
> +		goto error_free;
> +	}

I noticed that this driver is still using RTE_LOG directly.
The current desired behaviour is for each driver to define its own dynamic
log type (see i40e for an example).
  

Patch

diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index 6f8a6335b..29f494302 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -3172,9 +3172,17 @@  bnxt_dev_init(struct rte_eth_dev *eth_dev)
 	rc = bnxt_hwrm_ver_get(bp);
 	if (rc)
 		goto error_free;
-	bnxt_hwrm_queue_qportcfg(bp);
+	rc = bnxt_hwrm_queue_qportcfg(bp);
+	if (rc) {
+		RTE_LOG(ERR, PMD, "hwrm queue qportcfg failed\n");
+		goto error_free;
+	}
 
-	bnxt_hwrm_func_qcfg(bp);
+	rc = bnxt_hwrm_func_qcfg(bp);
+	if (rc) {
+		RTE_LOG(ERR, PMD, "hwrm func qcfg failed\n");
+		goto error_free;
+	}
 
 	/* Get the MAX capabilities for this function */
 	rc = bnxt_hwrm_func_qcaps(bp);