From 6133acbe8221c161c1a0e8d6e7ac1febb69d61a9 Mon Sep 17 00:00:00 2001 From: Xavier Simonart Date: Tue, 28 Jul 2015 16:54:39 +0200 Subject: [PATCH] hash: fix crash when adding already inserted keys When adding with cuckoo hash a key which was already inserted a new slot is dequeued and then enqueued back, but the enqueue operation was not done properly. Fixes: 48a399119619 ("hash: replace with cuckoo hash implementation") Signed-off-by: Xavier Simonart Acked-by: Sergio Gonzalez Monroy --- lib/librte_hash/rte_cuckoo_hash.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c index 5cf4af6988..4da859a6b7 100644 --- a/lib/librte_hash/rte_cuckoo_hash.c +++ b/lib/librte_hash/rte_cuckoo_hash.c @@ -509,7 +509,7 @@ __rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key, k = (struct rte_hash_key *) ((char *)keys + prim_bkt->key_idx[i] * h->key_entry_size); if (h->rte_hash_cmp_eq(key, k->key, h->key_len) == 0) { - rte_ring_sp_enqueue(h->free_slots, &slot_id); + rte_ring_sp_enqueue(h->free_slots, slot_id); /* Update data */ k->pdata = data; /* @@ -528,7 +528,7 @@ __rte_hash_add_key_with_hash(const struct rte_hash *h, const void *key, k = (struct rte_hash_key *) ((char *)keys + sec_bkt->key_idx[i] * h->key_entry_size); if (h->rte_hash_cmp_eq(key, k->key, h->key_len) == 0) { - rte_ring_sp_enqueue(h->free_slots, &slot_id); + rte_ring_sp_enqueue(h->free_slots, slot_id); /* Update data */ k->pdata = data; /* -- 2.20.1