Skip to content

Commit 07cf9d3

Browse files
Paul Blakeygregkh
authored andcommitted
rhashtable: Fix rhlist duplicates insertion
[ Upstream commit d3dcf8e ] When inserting duplicate objects (those with the same key), current rhlist implementation messes up the chain pointers by updating the bucket pointer instead of prev next pointer to the newly inserted node. This causes missing elements on removal and travesal. Fix that by properly updating pprev pointer to point to the correct rhash_head next pointer. Issue: 1241076 Change-Id: I86b2c140bcb4aeb10b70a72a267ff590bb2b17e7 Fixes: ca26893 ('rhashtable: Add rhlist interface') Signed-off-by: Paul Blakey <paulb@mellanox.com> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 090da7c commit 07cf9d3

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎include/linux/rhashtable.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,10 @@ static inline void *__rhashtable_insert_fast(
750750
if (!key ||
751751
(params.obj_cmpfn ?
752752
params.obj_cmpfn(&arg, rht_obj(ht, head)) :
753-
rhashtable_compare(&arg, rht_obj(ht, head))))
753+
rhashtable_compare(&arg, rht_obj(ht, head)))) {
754+
pprev = &head->next;
754755
continue;
756+
}
755757

756758
data = rht_obj(ht, head);
757759

‎lib/rhashtable.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,10 @@ static void *rhashtable_lookup_one(struct rhashtable *ht,
537537
if (!key ||
538538
(ht->p.obj_cmpfn ?
539539
ht->p.obj_cmpfn(&arg, rht_obj(ht, head)) :
540-
rhashtable_compare(&arg, rht_obj(ht, head))))
540+
rhashtable_compare(&arg, rht_obj(ht, head)))) {
541+
pprev = &head->next;
541542
continue;
543+
}
542544

543545
if (!ht->rhlist)
544546
return rht_obj(ht, head);

0 commit comments

Comments
 (0)