From 27c813679ea961b94d3184c09e50a055ad726da3 Mon Sep 17 00:00:00 2001 From: Yipeng Wang Date: Tue, 10 Jul 2018 09:59:54 -0700 Subject: [PATCH] hash: fix multiwriter lock memory allocation When malloc for multiwriter_lock, the align should be RTE_CACHE_LINE_SIZE rather than LCORE_CACHE_SIZE. Also there should be check to verify the success of rte_malloc. Fixes: be856325cba3 ("hash: add scalable multi-writer insertion with Intel TSX") Cc: stable@dpdk.org Signed-off-by: Yipeng Wang Acked-by: Pablo de Lara --- lib/librte_hash/rte_cuckoo_hash.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c index 375e7d208a..f8669a1964 100644 --- a/lib/librte_hash/rte_cuckoo_hash.c +++ b/lib/librte_hash/rte_cuckoo_hash.c @@ -280,7 +280,10 @@ rte_hash_create(const struct rte_hash_parameters *params) h->add_key = ADD_KEY_MULTIWRITER; h->multiwriter_lock = rte_malloc(NULL, sizeof(rte_spinlock_t), - LCORE_CACHE_SIZE); + RTE_CACHE_LINE_SIZE); + if (h->multiwriter_lock == NULL) + goto err_unlock; + rte_spinlock_init(h->multiwriter_lock); } } else -- 2.20.1