From 565789662e7bc7608681cb93e3ccf7a4a2744f0b Mon Sep 17 00:00:00 2001 From: Yunjian Wang Date: Mon, 7 Dec 2020 19:37:15 +0800 Subject: [PATCH] net/mvneta: check allocation in Rx queue flush The function rte_malloc() could return NULL, the return value need to be checked. Fixes: ce7ea764597e ("net/mvneta: support Rx/Tx") Cc: stable@dpdk.org Signed-off-by: Yunjian Wang Acked-by: Liron Himi --- drivers/net/mvneta/mvneta_rxtx.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/mvneta/mvneta_rxtx.c b/drivers/net/mvneta/mvneta_rxtx.c index 10b6f57584..dfa7ecc090 100644 --- a/drivers/net/mvneta/mvneta_rxtx.c +++ b/drivers/net/mvneta/mvneta_rxtx.c @@ -872,7 +872,17 @@ mvneta_rx_queue_flush(struct mvneta_rxq *rxq) int ret, i; descs = rte_malloc("rxdesc", MRVL_NETA_RXD_MAX * sizeof(*descs), 0); + if (descs == NULL) { + MVNETA_LOG(ERR, "Failed to allocate descs."); + return; + } + bufs = rte_malloc("buffs", MRVL_NETA_RXD_MAX * sizeof(*bufs), 0); + if (bufs == NULL) { + MVNETA_LOG(ERR, "Failed to allocate bufs."); + rte_free(descs); + return; + } do { num = MRVL_NETA_RXD_MAX; -- 2.20.1