patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [dpdk-dev] [PATCH] hash: fix dereference before null check
@ 2020-10-27 12:51 wangyunjian
  2020-10-27 14:59 ` Dharmik Thakkar
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: wangyunjian @ 2020-10-27 12:51 UTC (permalink / raw)
  To: dev, yipeng1.wang, sameh.gobriel
  Cc: bruce.richardson, dharmik.thakkar, jerry.lilijun, xudingke,
	Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

Coverity flags that 'h' variable is used before
it's checked for NULL. This patch fixes this issue.

Coverity issue: 363625
Fixes: 769b2de7fb52 ("hash: implement RCU resources reclamation")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 lib/librte_hash/rte_cuckoo_hash.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 7514e33aa9..1191dfd81a 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -1515,15 +1515,16 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg)
 	struct rte_rcu_qsbr_dq_parameters params = {0};
 	char rcu_dq_name[RTE_RCU_QSBR_DQ_NAMESIZE];
 	struct rte_hash_rcu_config *hash_rcu_cfg = NULL;
-	const uint32_t total_entries = h->use_local_cache ?
-		h->entries + (RTE_MAX_LCORE - 1) * (LCORE_CACHE_SIZE - 1) + 1
-							: h->entries + 1;
 
 	if (h == NULL || cfg == NULL || cfg->v == NULL) {
 		rte_errno = EINVAL;
 		return 1;
 	}
 
+	const uint32_t total_entries = h->use_local_cache ?
+		h->entries + (RTE_MAX_LCORE - 1) * (LCORE_CACHE_SIZE - 1) + 1
+							: h->entries + 1;
+
 	if (h->hash_rcu_cfg) {
 		rte_errno = EEXIST;
 		return 1;
-- 
2.23.0


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] hash: fix dereference before null check
  2020-10-27 12:51 [dpdk-stable] [dpdk-dev] [PATCH] hash: fix dereference before null check wangyunjian
@ 2020-10-27 14:59 ` Dharmik Thakkar
  2020-10-27 15:08   ` Dharmik Thakkar
  2020-10-28 16:25 ` Wang, Yipeng1
  2020-10-29 16:09 ` David Marchand
  2 siblings, 1 reply; 5+ messages in thread
From: Dharmik Thakkar @ 2020-10-27 14:59 UTC (permalink / raw)
  To: wangyunjian
  Cc: dev, yipeng1.wang, sameh.gobriel, bruce.richardson,
	jerry.lilijun, xudingke, stable

Hi Yunjian,

Thank you for fixing the issue!

> On Oct 27, 2020, at 7:51 AM, wangyunjian <wangyunjian@huawei.com> wrote:
>
> From: Yunjian Wang <wangyunjian@huawei.com>
>
> Coverity flags that 'h' variable is used before
> it's checked for NULL. This patch fixes this issue.
>
> Coverity issue: 363625
> Fixes: 769b2de7fb52 ("hash: implement RCU resources reclamation")
> Cc: stable@dpdk.org
>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
> lib/librte_hash/rte_cuckoo_hash.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
> index 7514e33aa9..1191dfd81a 100644
> --- a/lib/librte_hash/rte_cuckoo_hash.c
> +++ b/lib/librte_hash/rte_cuckoo_hash.c
> @@ -1515,15 +1515,16 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg)
> struct rte_rcu_qsbr_dq_parameters params = {0};
> char rcu_dq_name[RTE_RCU_QSBR_DQ_NAMESIZE];
> struct rte_hash_rcu_config *hash_rcu_cfg = NULL;
> -const uint32_t total_entries = h->use_local_cache ?
> -h->entries + (RTE_MAX_LCORE - 1) * (LCORE_CACHE_SIZE - 1) + 1
> -: h->entries + 1;
>
> if (h == NULL || cfg == NULL || cfg->v == NULL) {
> rte_errno = EINVAL;
> return 1;
> }
>
> +const uint32_t total_entries = h->use_local_cache ?
> +h->entries + (RTE_MAX_LCORE - 1) * (LCORE_CACHE_SIZE - 1) + 1
> +: h->entries + 1;
> +
> if (h->hash_rcu_cfg) {
> rte_errno = EEXIST;
> return 1;
> —
> 2.23.0
>


Reviewed-by: Dharmik Thakkar <dharmik.thakkar@arm.com>

IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] hash: fix dereference before null check
  2020-10-27 14:59 ` Dharmik Thakkar
@ 2020-10-27 15:08   ` Dharmik Thakkar
  0 siblings, 0 replies; 5+ messages in thread
From: Dharmik Thakkar @ 2020-10-27 15:08 UTC (permalink / raw)
  To: wangyunjian
  Cc: dev, yipeng1.wang, sameh.gobriel, bruce.richardson,
	jerry.lilijun, xudingke, stable, nd

Apologies for the disclaimer!

> On Oct 27, 2020, at 9:59 AM, Dharmik Thakkar <Dharmik.Thakkar@arm.com> wrote:
> 
> Hi Yunjian,
> 
> Thank you for fixing the issue!
> 
>> On Oct 27, 2020, at 7:51 AM, wangyunjian <wangyunjian@huawei.com> wrote:
>> 
>> From: Yunjian Wang <wangyunjian@huawei.com>
>> 
>> Coverity flags that 'h' variable is used before
>> it's checked for NULL. This patch fixes this issue.
>> 
>> Coverity issue: 363625
>> Fixes: 769b2de7fb52 ("hash: implement RCU resources reclamation")
>> Cc: stable@dpdk.org
>> 
>> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
>> ---
>> lib/librte_hash/rte_cuckoo_hash.c | 7 ++++---
>> 1 file changed, 4 insertions(+), 3 deletions(-)
>> 
>> diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
>> index 7514e33aa9..1191dfd81a 100644
>> --- a/lib/librte_hash/rte_cuckoo_hash.c
>> +++ b/lib/librte_hash/rte_cuckoo_hash.c
>> @@ -1515,15 +1515,16 @@ rte_hash_rcu_qsbr_add(struct rte_hash *h, struct rte_hash_rcu_config *cfg)
>> struct rte_rcu_qsbr_dq_parameters params = {0};
>> char rcu_dq_name[RTE_RCU_QSBR_DQ_NAMESIZE];
>> struct rte_hash_rcu_config *hash_rcu_cfg = NULL;
>> -const uint32_t total_entries = h->use_local_cache ?
>> -h->entries + (RTE_MAX_LCORE - 1) * (LCORE_CACHE_SIZE - 1) + 1
>> -: h->entries + 1;
>> 
>> if (h == NULL || cfg == NULL || cfg->v == NULL) {
>> rte_errno = EINVAL;
>> return 1;
>> }
>> 
>> +const uint32_t total_entries = h->use_local_cache ?
>> +h->entries + (RTE_MAX_LCORE - 1) * (LCORE_CACHE_SIZE - 1) + 1
>> +: h->entries + 1;
>> +
>> if (h->hash_rcu_cfg) {
>> rte_errno = EEXIST;
>> return 1;
>> —
>> 2.23.0
>> 
> 
> 
> Reviewed-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
> 


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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] hash: fix dereference before null check
  2020-10-27 12:51 [dpdk-stable] [dpdk-dev] [PATCH] hash: fix dereference before null check wangyunjian
  2020-10-27 14:59 ` Dharmik Thakkar
@ 2020-10-28 16:25 ` Wang, Yipeng1
  2020-10-29 16:09 ` David Marchand
  2 siblings, 0 replies; 5+ messages in thread
From: Wang, Yipeng1 @ 2020-10-28 16:25 UTC (permalink / raw)
  To: wangyunjian, dev, Gobriel, Sameh
  Cc: Richardson, Bruce, dharmik.thakkar, jerry.lilijun, xudingke, stable

> -----Original Message-----
> From: wangyunjian <wangyunjian@huawei.com>
> Sent: Tuesday, October 27, 2020 5:51 AM
> To: dev@dpdk.org; Wang, Yipeng1 <yipeng1.wang@intel.com>; Gobriel, Sameh
> <sameh.gobriel@intel.com>
> Cc: Richardson, Bruce <bruce.richardson@intel.com>;
> dharmik.thakkar@arm.com; jerry.lilijun@huawei.com; xudingke@huawei.com;
> Yunjian Wang <wangyunjian@huawei.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] hash: fix dereference before null check
> 
> From: Yunjian Wang <wangyunjian@huawei.com>
> 
> Coverity flags that 'h' variable is used before it's checked for NULL. This patch
> fixes this issue.
> 
> Coverity issue: 363625
> Fixes: 769b2de7fb52 ("hash: implement RCU resources reclamation")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
 [Wang, Yipeng] 
Thanks for the fix!

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



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

* Re: [dpdk-stable] [dpdk-dev] [PATCH] hash: fix dereference before null check
  2020-10-27 12:51 [dpdk-stable] [dpdk-dev] [PATCH] hash: fix dereference before null check wangyunjian
  2020-10-27 14:59 ` Dharmik Thakkar
  2020-10-28 16:25 ` Wang, Yipeng1
@ 2020-10-29 16:09 ` David Marchand
  2 siblings, 0 replies; 5+ messages in thread
From: David Marchand @ 2020-10-29 16:09 UTC (permalink / raw)
  To: wangyunjian
  Cc: dev, Wang, Yipeng1, Gobriel, Sameh, Bruce Richardson,
	Dharmik Thakkar, Lilijun (Jerry),
	xudingke, dpdk stable

On Tue, Oct 27, 2020 at 1:52 PM wangyunjian <wangyunjian@huawei.com> wrote:
>
> From: Yunjian Wang <wangyunjian@huawei.com>
>
> Coverity flags that 'h' variable is used before
> it's checked for NULL. This patch fixes this issue.
>
> Coverity issue: 363625
> Fixes: 769b2de7fb52 ("hash: implement RCU resources reclamation")

No need to copy stable, this feature is only in the current release.


> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
Reviewed-by: Dharmik Thakkar <dharmik.thakkar@arm.com>
Acked-by: Yipeng Wang <yipeng1.wang@intel.com>


Applied, thanks.

-- 
David Marchand


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

end of thread, other threads:[~2020-10-29 16:10 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27 12:51 [dpdk-stable] [dpdk-dev] [PATCH] hash: fix dereference before null check wangyunjian
2020-10-27 14:59 ` Dharmik Thakkar
2020-10-27 15:08   ` Dharmik Thakkar
2020-10-28 16:25 ` Wang, Yipeng1
2020-10-29 16:09 ` David Marchand

patches for DPDK stable branches

This inbox may be cloned and mirrored by anyone:

	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

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