[09/20] net/dpaa: fix a memory leak when validation fail

Message ID tencent_EBBE8747EE443C62B079A24E7922F674A609@qq.com (mailing list archive)
State Changes Requested, archived
Delegated to: David Marchand
Headers
Series fix memory leaks in error handling |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Weiguo Li Feb. 22, 2022, 6:18 p.m. UTC
  When buf_len validations fails and return, the mbuf is not freed
which caused a memory leak.

Fixes: 8cffdcbe85aa ("net/dpaa: support scattered Rx")

Signed-off-by: Weiguo Li <liwg06@foxmail.com>
---
 drivers/net/dpaa/dpaa_rxtx.c | 1 +
 1 file changed, 1 insertion(+)
  

Patch

diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 956fe946fa..f66d975969 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -810,6 +810,7 @@  dpaa_eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf,
 	}
 	if (temp->buf_len < ((mbuf->nb_segs * sizeof(struct qm_sg_entry))
 				+ temp->data_off)) {
+		rte_pktmbuf_free(temp);
 		DPAA_PMD_ERR("Insufficient space in mbuf for SG entries");
 		return -1;
 	}