[dpdk-dev] [EXT] [PATCH] net/mvneta: check allocation in rx queue flush

wangyunjian wangyunjian at huawei.com
Mon Dec 7 14:07:45 CET 2020


> -----Original Message-----
> From: Liron Himi [mailto:lironh at marvell.com]
> Sent: Monday, December 7, 2020 8:38 PM
> To: wangyunjian <wangyunjian at huawei.com>; dev at dpdk.org
> Cc: zr at semihalf.com; Lilijun (Jerry) <jerry.lilijun at huawei.com>; xudingke
> <xudingke at huawei.com>; stable at dpdk.org; Liron Himi <lironh at marvell.com>
> Subject: RE: [EXT] [dpdk-dev] [PATCH] net/mvneta: check allocation in rx queue
> flush
> 
> Hi,
> 
> How about use 2 local arrays for descs & bufs instead of the malloc/free?

The definition of these 2 arrays is 2048. If it is a local array, is it too large?

> 
> Liron
> 
> 
> -----Original Message-----
> From: wangyunjian <wangyunjian at huawei.com>
> Sent: Monday, 7 December 2020 13:37
> To: dev at dpdk.org
> Cc: Liron Himi <lironh at marvell.com>; zr at semihalf.com;
> jerry.lilijun at huawei.com; xudingke at huawei.com; Yunjian Wang
> <wangyunjian at huawei.com>; stable at dpdk.org
> Subject: [EXT] [dpdk-dev] [PATCH] net/mvneta: check allocation in rx queue flush
> 
> External Email
> 
> ----------------------------------------------------------------------
> From: Yunjian Wang <wangyunjian at huawei.com>
> 
> The function rte_malloc() could return NULL, the return value need to be
> checked.
> 
> Fixes: ce7ea764597e ("net/mvneta: support Rx/Tx")
> Cc: stable at dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian at huawei.com>
> ---
>  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.23.0



More information about the dev mailing list