diff mbox series

net/bnxt: fix a memory leak when new malloc fail

Message ID tencent_60C640F1849CF244D8EA007DBB8D1089800A@qq.com (mailing list archive)
State Superseded, archived
Delegated to: Ajit Khaparde
Headers show
Series net/bnxt: fix a memory leak when new malloc fail | expand


Context Check Description
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Weiguo Li Feb. 18, 2022, 6:05 p.m. UTC
When new memory is not available and the memory "ctx" allocated
beforehand was not assigned to anywhere, so "ctx" should be freed,
otherwise will cause a memory leak.

Fixes: b4f740511655 ("net/bnxt: remove unnecessary return check")

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
 drivers/net/bnxt/bnxt_hwrm.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series


diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c
index b4aeec593e..4993111ccf 100644
--- a/drivers/net/bnxt/bnxt_hwrm.c
+++ b/drivers/net/bnxt/bnxt_hwrm.c
@@ -5374,6 +5374,7 @@  int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp)
 	if (!ctx_pg) {
 		rc = -ENOMEM;
+		rte_free(ctx);
 		goto ctx_err;
 	for (i = 0; i < tqm_rings; i++, ctx_pg++)