[2/2] net/bnxt: add memory allocation check in vf_info init
diff mbox series

Message ID f25865c1d667be9d34151bc893de9436efe06b6c.1596196484.git.wangyunjian@huawei.com
State Accepted
Delegated to: Ajit Khaparde
Headers show
Series
  • fixes for bnxt driver
Related show

Checks

Context Check Description
ci/travis-robot success Travis build: passed
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

wangyunjian July 31, 2020, 12:09 p.m. UTC
From: Yunjian Wang <wangyunjian@huawei.com>

The function rte_malloc() could return NULL, the return
value need to be checked.

Fixes: b7778e8a1c00 ("net/bnxt: refactor to properly allocate resources for PF/VF")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/bnxt/bnxt_hwrm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index 643dd9897..43e3e2753 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -711,8 +711,12 @@  static int __bnxt_hwrm_func_qcaps(struct bnxt *bp)
 		if (new_max_vfs != bp->pf->max_vfs) {
 			if (bp->pf->vf_info)
 				bnxt_hwrm_free_vf_info(bp);
-			bp->pf->vf_info = rte_malloc("bnxt_vf_info",
+			bp->pf->vf_info = rte_zmalloc("bnxt_vf_info",
 			    sizeof(bp->pf->vf_info[0]) * new_max_vfs, 0);
+			if (bp->pf->vf_info == NULL) {
+				PMD_DRV_LOG(ERR, "Alloc vf info fail\n");
+				return -ENOMEM;
+			}
 			bp->pf->max_vfs = new_max_vfs;
 			for (i = 0; i < new_max_vfs; i++) {
 				bp->pf->vf_info[i].fid =