patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [dpdk-dev] [PATCH] net/mvneta: check allocation in rx queue flush
@ 2020-12-07 11:37 wangyunjian
  2020-12-07 12:37 ` [dpdk-stable] [EXT] " Liron Himi
  2021-01-12 14:21 ` [dpdk-stable] " Jerin Jacob
  0 siblings, 2 replies; 5+ messages in thread
From: wangyunjian @ 2020-12-07 11:37 UTC (permalink / raw)
  To: dev; +Cc: lironh, zr, jerry.lilijun, xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@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@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-stable] [EXT] [dpdk-dev] [PATCH] net/mvneta: check allocation in rx queue flush
  2020-12-07 11:37 [dpdk-stable] [dpdk-dev] [PATCH] net/mvneta: check allocation in rx queue flush wangyunjian
@ 2020-12-07 12:37 ` Liron Himi
  2020-12-07 13:07   ` wangyunjian
  2021-01-12 14:21 ` [dpdk-stable] " Jerin Jacob
  1 sibling, 1 reply; 5+ messages in thread
From: Liron Himi @ 2020-12-07 12:37 UTC (permalink / raw)
  To: wangyunjian, dev; +Cc: zr, jerry.lilijun, xudingke, stable, Liron Himi

Hi,

How about use 2 local arrays for descs & bufs instead of the malloc/free? 

Liron


-----Original Message-----
From: wangyunjian <wangyunjian@huawei.com> 
Sent: Monday, 7 December 2020 13:37
To: dev@dpdk.org
Cc: Liron Himi <lironh@marvell.com>; zr@semihalf.com; jerry.lilijun@huawei.com; xudingke@huawei.com; Yunjian Wang <wangyunjian@huawei.com>; stable@dpdk.org
Subject: [EXT] [dpdk-dev] [PATCH] net/mvneta: check allocation in rx queue flush

External Email

----------------------------------------------------------------------
From: Yunjian Wang <wangyunjian@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@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-stable] [EXT] [dpdk-dev] [PATCH] net/mvneta: check allocation in rx queue flush
  2020-12-07 12:37 ` [dpdk-stable] [EXT] " Liron Himi
@ 2020-12-07 13:07   ` wangyunjian
  2020-12-15 22:29     ` Liron Himi
  0 siblings, 1 reply; 5+ messages in thread
From: wangyunjian @ 2020-12-07 13:07 UTC (permalink / raw)
  To: Liron Himi, dev; +Cc: zr, Lilijun (Jerry), xudingke, stable

> -----Original Message-----
> From: Liron Himi [mailto:lironh@marvell.com]
> Sent: Monday, December 7, 2020 8:38 PM
> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> Cc: zr@semihalf.com; Lilijun (Jerry) <jerry.lilijun@huawei.com>; xudingke
> <xudingke@huawei.com>; stable@dpdk.org; Liron Himi <lironh@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@huawei.com>
> Sent: Monday, 7 December 2020 13:37
> To: dev@dpdk.org
> Cc: Liron Himi <lironh@marvell.com>; zr@semihalf.com;
> jerry.lilijun@huawei.com; xudingke@huawei.com; Yunjian Wang
> <wangyunjian@huawei.com>; stable@dpdk.org
> Subject: [EXT] [dpdk-dev] [PATCH] net/mvneta: check allocation in rx queue flush
> 
> External Email
> 
> ----------------------------------------------------------------------
> From: Yunjian Wang <wangyunjian@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@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-stable] [EXT] [dpdk-dev] [PATCH] net/mvneta: check allocation in rx queue flush
  2020-12-07 13:07   ` wangyunjian
@ 2020-12-15 22:29     ` Liron Himi
  0 siblings, 0 replies; 5+ messages in thread
From: Liron Himi @ 2020-12-15 22:29 UTC (permalink / raw)
  To: wangyunjian, dev; +Cc: zr, Lilijun (Jerry), xudingke, stable, Liron Himi

-----Original Message-----
From: wangyunjian <wangyunjian@huawei.com> 
Sent: Monday, 7 December 2020 15:08
To: Liron Himi <lironh@marvell.com>; dev@dpdk.org
Cc: zr@semihalf.com; Lilijun (Jerry) <jerry.lilijun@huawei.com>; xudingke <xudingke@huawei.com>; stable@dpdk.org
Subject: RE: [EXT] [dpdk-dev] [PATCH] net/mvneta: check allocation in rx queue flush

> -----Original Message-----
> From: Liron Himi [mailto:lironh@marvell.com]
> Sent: Monday, December 7, 2020 8:38 PM
> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> Cc: zr@semihalf.com; Lilijun (Jerry) <jerry.lilijun@huawei.com>; 
> xudingke <xudingke@huawei.com>; stable@dpdk.org; Liron Himi 
> <lironh@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?
[L.H.] I'm not sure. Lets stay with your original patch. 

Acked-by: Liron Himi <lironh@marvell.com>

> 
> Liron
> 
> 
> -----Original Message-----
> From: wangyunjian <wangyunjian@huawei.com>
> Sent: Monday, 7 December 2020 13:37
> To: dev@dpdk.org
> Cc: Liron Himi <lironh@marvell.com>; zr@semihalf.com; 
> jerry.lilijun@huawei.com; xudingke@huawei.com; Yunjian Wang 
> <wangyunjian@huawei.com>; stable@dpdk.org
> Subject: [EXT] [dpdk-dev] [PATCH] net/mvneta: check allocation in rx 
> queue flush
> 
> External Email
> 
> ----------------------------------------------------------------------
> From: Yunjian Wang <wangyunjian@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@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH] net/mvneta: check allocation in rx queue flush
  2020-12-07 11:37 [dpdk-stable] [dpdk-dev] [PATCH] net/mvneta: check allocation in rx queue flush wangyunjian
  2020-12-07 12:37 ` [dpdk-stable] [EXT] " Liron Himi
@ 2021-01-12 14:21 ` Jerin Jacob
  1 sibling, 0 replies; 5+ messages in thread
From: Jerin Jacob @ 2021-01-12 14:21 UTC (permalink / raw)
  To: wangyunjian, Ferruh Yigit
  Cc: dpdk-dev, Liron Himi, Zyta Szpak, Lilijun (Jerry), xudingke, dpdk stable

On Mon, Dec 7, 2020 at 5:07 PM wangyunjian <wangyunjian@huawei.com> wrote:
>
> From: Yunjian Wang <wangyunjian@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@dpdk.org
>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>

Acked-by: Liron Himi <lironh@marvell.com>
Applied to dpdk-next-net-mrvl/for-main. Thanks



> ---
>  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
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-12 14:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07 11:37 [dpdk-stable] [dpdk-dev] [PATCH] net/mvneta: check allocation in rx queue flush wangyunjian
2020-12-07 12:37 ` [dpdk-stable] [EXT] " Liron Himi
2020-12-07 13:07   ` wangyunjian
2020-12-15 22:29     ` Liron Himi
2021-01-12 14:21 ` [dpdk-stable] " Jerin Jacob

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ https://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git