[dpdk-dev] hash: fix array out of bounds in hash library

Message ID 1436964043-5729-1-git-send-email-pablo.de.lara.guarch@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

De Lara Guarch, Pablo July 15, 2015, 12:40 p.m. UTC
  When encountering a loop while adding a new entry,
element out of bounds of array was being unnecessarily resetted.

Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation")

Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>
---
 lib/librte_hash/rte_cuckoo_hash.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
  

Comments

Thomas Monjalon July 16, 2015, 2:55 p.m. UTC | #1
2015-07-15 13:40, Pablo de Lara:
> When encountering a loop while adding a new entry,
> element out of bounds of array was being unnecessarily resetted.
> 
> Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation")
> 
> Signed-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c
index 93f94a5..b753e77 100644
--- a/lib/librte_hash/rte_cuckoo_hash.c
+++ b/lib/librte_hash/rte_cuckoo_hash.c
@@ -446,11 +446,8 @@  make_space_bucket(const struct rte_hash *h, struct rte_hash_bucket *bkt)
 			break;
 
 	/* All entries have been pushed, so entry cannot be added */
-	if (i == RTE_HASH_BUCKET_ENTRIES) {
-		/* Reset flag */
-		bkt->flag[i] = 0;
+	if (i == RTE_HASH_BUCKET_ENTRIES)
 		return -ENOSPC;
-	}
 
 	/* Set flag to indicate that this entry is going to be pushed */
 	bkt->flag[i] = 1;