patches for DPDK stable branches
 help / color / Atom feed
* [dpdk-stable] [dpdk-dev] [PATCH] hash: fix return value of null not checked
@ 2020-07-21 13:31 wangyunjian
  2020-07-21 17:26 ` Honnappa Nagarahalli
  2020-07-22  3:58 ` [dpdk-stable] [dpdk-dev] [PATCH v2] " wangyunjian
  0 siblings, 2 replies; 6+ messages in thread
From: wangyunjian @ 2020-07-21 13:31 UTC (permalink / raw)
  To: dev
  Cc: yipeng1.wang, sameh.gobriel, bruce.richardson, jerry.lilijun,
	xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

The function rte_zmalloc_socket() could return NULL, the return
value need to be checked.

Fixes: 5915699153d7 ("hash: fix scaling by reducing contention")
Cc: stable@dpdk.org

Reported-by: HuangBin <brian.huangbin@huawei.com>
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 lib/librte_hash/rte_cuckoo_hash.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 5f701d579..0a6d47471 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -151,6 +151,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	unsigned int no_free_on_del = 0;
 	uint32_t *ext_bkt_to_free = NULL;
 	uint32_t *tbl_chng_cnt = NULL;
+	struct lcore_cache *local_free_slots = NULL;
 	unsigned int readwrite_concur_lf_support = 0;
 	uint32_t i;
 
@@ -383,9 +384,13 @@ rte_hash_create(const struct rte_hash_parameters *params)
 #endif
 
 	if (use_local_cache) {
-		h->local_free_slots = rte_zmalloc_socket(NULL,
+		local_free_slots = rte_zmalloc_socket(NULL,
 				sizeof(struct lcore_cache) * RTE_MAX_LCORE,
 				RTE_CACHE_LINE_SIZE, params->socket_id);
+		if (local_free_slots == NULL) {
+			RTE_LOG(ERR, HASH, "local free slots memory allocation failed\n");
+			goto err_unlock;
+		}
 	}
 
 	/* Default hash function */
@@ -416,6 +421,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	*h->tbl_chng_cnt = 0;
 	h->hw_trans_mem_support = hw_trans_mem_support;
 	h->use_local_cache = use_local_cache;
+	h->local_free_slots = local_free_slots;
 	h->readwrite_concur_support = readwrite_concur_support;
 	h->ext_table_support = ext_table_support;
 	h->writer_takes_lock = writer_takes_lock;
@@ -461,6 +467,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	rte_ring_free(r);
 	rte_ring_free(r_ext);
 	rte_free(te);
+	rte_free(local_free_slots);
 	rte_free(h);
 	rte_free(buckets);
 	rte_free(buckets_ext);
-- 
2.23.0



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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] hash: fix return value of null not checked
  2020-07-21 13:31 [dpdk-stable] [dpdk-dev] [PATCH] hash: fix return value of null not checked wangyunjian
@ 2020-07-21 17:26 ` Honnappa Nagarahalli
  2020-07-21 20:24   ` Wang, Yipeng1
  2020-07-22  3:58 ` [dpdk-stable] [dpdk-dev] [PATCH v2] " wangyunjian
  1 sibling, 1 reply; 6+ messages in thread
From: Honnappa Nagarahalli @ 2020-07-21 17:26 UTC (permalink / raw)
  To: wangyunjian, dev
  Cc: yipeng1.wang, sameh.gobriel, bruce.richardson, jerry.lilijun,
	xudingke, stable, nd, Honnappa Nagarahalli, nd



> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of wangyunjian
> Sent: Tuesday, July 21, 2020 8:32 AM
> To: dev@dpdk.org
> Cc: yipeng1.wang@intel.com; sameh.gobriel@intel.com;
> bruce.richardson@intel.com; jerry.lilijun@huawei.com;
> xudingke@huawei.com; Yunjian Wang <wangyunjian@huawei.com>;
> stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] hash: fix return value of null not checked
> 
> From: Yunjian Wang <wangyunjian@huawei.com>
> 
> The function rte_zmalloc_socket() could return NULL, the return value need to
> be checked.
> 
> Fixes: 5915699153d7 ("hash: fix scaling by reducing contention")
> Cc: stable@dpdk.org
> 
> Reported-by: HuangBin <brian.huangbin@huawei.com>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Good catch
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>

> ---
>  lib/librte_hash/rte_cuckoo_hash.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_hash/rte_cuckoo_hash.c
> b/lib/librte_hash/rte_cuckoo_hash.c
> index 5f701d579..0a6d47471 100644
> --- a/lib/librte_hash/rte_cuckoo_hash.c
> +++ b/lib/librte_hash/rte_cuckoo_hash.c
> @@ -151,6 +151,7 @@ rte_hash_create(const struct rte_hash_parameters
> *params)
>  	unsigned int no_free_on_del = 0;
>  	uint32_t *ext_bkt_to_free = NULL;
>  	uint32_t *tbl_chng_cnt = NULL;
> +	struct lcore_cache *local_free_slots = NULL;
>  	unsigned int readwrite_concur_lf_support = 0;
>  	uint32_t i;
> 
> @@ -383,9 +384,13 @@ rte_hash_create(const struct rte_hash_parameters
> *params)  #endif
> 
>  	if (use_local_cache) {
> -		h->local_free_slots = rte_zmalloc_socket(NULL,
> +		local_free_slots = rte_zmalloc_socket(NULL,
>  				sizeof(struct lcore_cache) * RTE_MAX_LCORE,
>  				RTE_CACHE_LINE_SIZE, params->socket_id);
> +		if (local_free_slots == NULL) {
> +			RTE_LOG(ERR, HASH, "local free slots memory
> allocation failed\n");
> +			goto err_unlock;
> +		}
>  	}
> 
>  	/* Default hash function */
> @@ -416,6 +421,7 @@ rte_hash_create(const struct rte_hash_parameters
> *params)
>  	*h->tbl_chng_cnt = 0;
>  	h->hw_trans_mem_support = hw_trans_mem_support;
>  	h->use_local_cache = use_local_cache;
> +	h->local_free_slots = local_free_slots;
>  	h->readwrite_concur_support = readwrite_concur_support;
>  	h->ext_table_support = ext_table_support;
>  	h->writer_takes_lock = writer_takes_lock; @@ -461,6 +467,7 @@
> rte_hash_create(const struct rte_hash_parameters *params)
>  	rte_ring_free(r);
>  	rte_ring_free(r_ext);
>  	rte_free(te);
> +	rte_free(local_free_slots);
>  	rte_free(h);
>  	rte_free(buckets);
>  	rte_free(buckets_ext);
> --
> 2.23.0
> 


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] hash: fix return value of null not checked
  2020-07-21 17:26 ` Honnappa Nagarahalli
@ 2020-07-21 20:24   ` Wang, Yipeng1
  2020-07-22  3:20     ` wangyunjian
  0 siblings, 1 reply; 6+ messages in thread
From: Wang, Yipeng1 @ 2020-07-21 20:24 UTC (permalink / raw)
  To: Honnappa Nagarahalli, wangyunjian, dev
  Cc: Gobriel, Sameh, Richardson, Bruce, jerry.lilijun, xudingke, stable, nd

> -----Original Message-----
> From: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
> Sent: Tuesday, July 21, 2020 10:27 AM
> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> Cc: Wang, Yipeng1 <yipeng1.wang@intel.com>; Gobriel, Sameh
> <sameh.gobriel@intel.com>; Richardson, Bruce <bruce.richardson@intel.com>;
> jerry.lilijun@huawei.com; xudingke@huawei.com; stable@dpdk.org; nd
> <nd@arm.com>; Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>;
> nd <nd@arm.com>
> Subject: RE: [dpdk-dev] [PATCH] hash: fix return value of null not checked
> 
> 
> 
> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of wangyunjian
> > Sent: Tuesday, July 21, 2020 8:32 AM
> > To: dev@dpdk.org
> > Cc: yipeng1.wang@intel.com; sameh.gobriel@intel.com;
> > bruce.richardson@intel.com; jerry.lilijun@huawei.com;
> > xudingke@huawei.com; Yunjian Wang <wangyunjian@huawei.com>;
> > stable@dpdk.org
> > Subject: [dpdk-dev] [PATCH] hash: fix return value of null not checked
> >
> > From: Yunjian Wang <wangyunjian@huawei.com>
> >
> > The function rte_zmalloc_socket() could return NULL, the return value
> > need to be checked.
> >
> > Fixes: 5915699153d7 ("hash: fix scaling by reducing contention")
> > Cc: stable@dpdk.org
> >
> > Reported-by: HuangBin <brian.huangbin@huawei.com>
[Wang, Yipeng] missed a space in name?

> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> Good catch
> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
[Wang, Yipeng] 
Thanks for the fix!

Acked-by: Yipeng Wang <yipeng1.wang@intel.com>

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] hash: fix return value of null not checked
  2020-07-21 20:24   ` Wang, Yipeng1
@ 2020-07-22  3:20     ` wangyunjian
  0 siblings, 0 replies; 6+ messages in thread
From: wangyunjian @ 2020-07-22  3:20 UTC (permalink / raw)
  To: Wang, Yipeng1, Honnappa Nagarahalli, dev
  Cc: Gobriel, Sameh, Richardson, Bruce, Lilijun (Jerry), xudingke, stable, nd

> -----Original Message-----
> From: Wang, Yipeng1 [mailto:yipeng1.wang@intel.com]
> Sent: Wednesday, July 22, 2020 4:24 AM
> To: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>; wangyunjian
> <wangyunjian@huawei.com>; dev@dpdk.org
> Cc: Gobriel, Sameh <sameh.gobriel@intel.com>; Richardson, Bruce
> <bruce.richardson@intel.com>; Lilijun (Jerry) <jerry.lilijun@huawei.com>;
> xudingke <xudingke@huawei.com>; stable@dpdk.org; nd <nd@arm.com>
> Subject: RE: [dpdk-dev] [PATCH] hash: fix return value of null not checked
> 
> > -----Original Message-----
> > From: Honnappa Nagarahalli <Honnappa.Nagarahalli@arm.com>
> > Sent: Tuesday, July 21, 2020 10:27 AM
> > To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> > Cc: Wang, Yipeng1 <yipeng1.wang@intel.com>; Gobriel, Sameh
> > <sameh.gobriel@intel.com>; Richardson, Bruce
> > <bruce.richardson@intel.com>; jerry.lilijun@huawei.com;
> > xudingke@huawei.com; stable@dpdk.org; nd <nd@arm.com>; Honnappa
> > Nagarahalli <Honnappa.Nagarahalli@arm.com>; nd <nd@arm.com>
> > Subject: RE: [dpdk-dev] [PATCH] hash: fix return value of null not
> > checked
> >
> >
> >
> > > -----Original Message-----
> > > From: dev <dev-bounces@dpdk.org> On Behalf Of wangyunjian
> > > Sent: Tuesday, July 21, 2020 8:32 AM
> > > To: dev@dpdk.org
> > > Cc: yipeng1.wang@intel.com; sameh.gobriel@intel.com;
> > > bruce.richardson@intel.com; jerry.lilijun@huawei.com;
> > > xudingke@huawei.com; Yunjian Wang <wangyunjian@huawei.com>;
> > > stable@dpdk.org
> > > Subject: [dpdk-dev] [PATCH] hash: fix return value of null not
> > > checked
> > >
> > > From: Yunjian Wang <wangyunjian@huawei.com>
> > >
> > > The function rte_zmalloc_socket() could return NULL, the return
> > > value need to be checked.
> > >
> > > Fixes: 5915699153d7 ("hash: fix scaling by reducing contention")
> > > Cc: stable@dpdk.org
> > >
> > > Reported-by: HuangBin <brian.huangbin@huawei.com>
> [Wang, Yipeng] missed a space in name?

Thanks, I will send v2 with correction.

Yunjian

> 
> > > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > Good catch
> > Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> [Wang, Yipeng]
> Thanks for the fix!
> 
> Acked-by: Yipeng Wang <yipeng1.wang@intel.com>

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

* [dpdk-stable] [dpdk-dev] [PATCH v2] hash: fix return value of null not checked
  2020-07-21 13:31 [dpdk-stable] [dpdk-dev] [PATCH] hash: fix return value of null not checked wangyunjian
  2020-07-21 17:26 ` Honnappa Nagarahalli
@ 2020-07-22  3:58 ` " wangyunjian
  2020-07-27 11:29   ` David Marchand
  1 sibling, 1 reply; 6+ messages in thread
From: wangyunjian @ 2020-07-22  3:58 UTC (permalink / raw)
  To: dev
  Cc: yipeng1.wang, sameh.gobriel, bruce.richardson, jerry.lilijun,
	xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

The function rte_zmalloc_socket() could return NULL, the return
value need to be checked.

Fixes: 5915699153d7 ("hash: fix scaling by reducing contention")
Cc: stable@dpdk.org

Reported-by: Bin Huang <brian.huangbin@huawei.com>
Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
Acked-by: Yipeng Wang <yipeng1.wang@intel.com>
---
v2:
* Update commit log
---
 lib/librte_hash/rte_cuckoo_hash.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 5f701d579..0a6d47471 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -151,6 +151,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	unsigned int no_free_on_del = 0;
 	uint32_t *ext_bkt_to_free = NULL;
 	uint32_t *tbl_chng_cnt = NULL;
+	struct lcore_cache *local_free_slots = NULL;
 	unsigned int readwrite_concur_lf_support = 0;
 	uint32_t i;
 
@@ -383,9 +384,13 @@ rte_hash_create(const struct rte_hash_parameters *params)
 #endif
 
 	if (use_local_cache) {
-		h->local_free_slots = rte_zmalloc_socket(NULL,
+		local_free_slots = rte_zmalloc_socket(NULL,
 				sizeof(struct lcore_cache) * RTE_MAX_LCORE,
 				RTE_CACHE_LINE_SIZE, params->socket_id);
+		if (local_free_slots == NULL) {
+			RTE_LOG(ERR, HASH, "local free slots memory allocation failed\n");
+			goto err_unlock;
+		}
 	}
 
 	/* Default hash function */
@@ -416,6 +421,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	*h->tbl_chng_cnt = 0;
 	h->hw_trans_mem_support = hw_trans_mem_support;
 	h->use_local_cache = use_local_cache;
+	h->local_free_slots = local_free_slots;
 	h->readwrite_concur_support = readwrite_concur_support;
 	h->ext_table_support = ext_table_support;
 	h->writer_takes_lock = writer_takes_lock;
@@ -461,6 +467,7 @@ rte_hash_create(const struct rte_hash_parameters *params)
 	rte_ring_free(r);
 	rte_ring_free(r_ext);
 	rte_free(te);
+	rte_free(local_free_slots);
 	rte_free(h);
 	rte_free(buckets);
 	rte_free(buckets_ext);
-- 
2.23.0



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

* Re: [dpdk-stable] [dpdk-dev] [PATCH v2] hash: fix return value of null not checked
  2020-07-22  3:58 ` [dpdk-stable] [dpdk-dev] [PATCH v2] " wangyunjian
@ 2020-07-27 11:29   ` David Marchand
  0 siblings, 0 replies; 6+ messages in thread
From: David Marchand @ 2020-07-27 11:29 UTC (permalink / raw)
  To: wangyunjian
  Cc: dev, Wang, Yipeng1, Gobriel, Sameh, Bruce Richardson,
	Lilijun (Jerry),
	xudingke, dpdk stable

On Wed, Jul 22, 2020 at 5:59 AM wangyunjian <wangyunjian@huawei.com> wrote:
> The function rte_zmalloc_socket() could return NULL, the return
> value need to be checked.
>
> Fixes: 5915699153d7 ("hash: fix scaling by reducing contention")
> Cc: stable@dpdk.org
>
> Reported-by: Bin Huang <brian.huangbin@huawei.com>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> Reviewed-by: Honnappa Nagarahalli <honnappa.nagarahalli@arm.com>
> Acked-by: Yipeng Wang <yipeng1.wang@intel.com>

Applied, thanks.


-- 
David Marchand


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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-21 13:31 [dpdk-stable] [dpdk-dev] [PATCH] hash: fix return value of null not checked wangyunjian
2020-07-21 17:26 ` Honnappa Nagarahalli
2020-07-21 20:24   ` Wang, Yipeng1
2020-07-22  3:20     ` wangyunjian
2020-07-22  3:58 ` [dpdk-stable] [dpdk-dev] [PATCH v2] " wangyunjian
2020-07-27 11:29   ` David Marchand

patches for DPDK stable branches

Archives are clonable:
	git clone --mirror http://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/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


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