[dpdk-dev] [PATCH] hash: fix dereference before null check

Dharmik Thakkar Dharmik.Thakkar at arm.com
Tue Oct 27 16:08:09 CET 2020


Apologies for the disclaimer!

> On Oct 27, 2020, at 9:59 AM, Dharmik Thakkar <Dharmik.Thakkar at arm.com> wrote:
> 
> Hi Yunjian,
> 
> Thank you for fixing the issue!
> 
>> On Oct 27, 2020, at 7:51 AM, wangyunjian <wangyunjian at huawei.com> wrote:
>> 
>> From: Yunjian Wang <wangyunjian at 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 at dpdk.org
>> 
>> Signed-off-by: Yunjian Wang <wangyunjian at 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 at arm.com>
> 



More information about the dev mailing list