From mboxrd@z Thu Jan 1 00:00:00 1970 From: mstolarchuk Subject: [PATCH] __rte_hash_add_key_with_hash not releasing multiwriter_lock in failure paths Date: Fri, 26 May 2017 05:30:30 -0700 Message-ID: <1495801830-36849-1-git-send-email-mike.stolarchuk@bigswitch.com> Cc: dev@dpdk.org To: bruce.richardson@intel.co Return-path: Received: from mail-pf0-f174.google.com (mail-pf0-f174.google.com [209.85.192.174]) by dpdk.org (Postfix) with ESMTP id C4BF3A0B2 for ; Fri, 26 May 2017 14:30:33 +0200 (CEST) Received: by mail-pf0-f174.google.com with SMTP id m17so10544236pfg.3 for ; Fri, 26 May 2017 05:30:33 -0700 (PDT) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Signed-off-by: mstolarchuk --- lib/librte_hash/rte_cuckoo_hash.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/librte_hash/rte_cuckoo_hash.c b/lib/librte_hash/rte_cuckoo_hash.c index 645c0cf..37a8110 100644 --- a/lib/librte_hash/rte_cuckoo_hash.c +++ b/lib/librte_hash/rte_cuckoo_hash.c @@ -538,8 +538,10 @@ struct rte_hash * n_slots = rte_ring_mc_dequeue_burst(h->free_slots, cached_free_slots->objs, LCORE_CACHE_SIZE, NULL); - if (n_slots == 0) - return -ENOSPC; + if (n_slots == 0) { + ret = -ENOSPC; + goto failure; + } cached_free_slots->len += n_slots; } @@ -548,8 +550,10 @@ struct rte_hash * cached_free_slots->len--; slot_id = cached_free_slots->objs[cached_free_slots->len]; } else { - if (rte_ring_sc_dequeue(h->free_slots, &slot_id) != 0) - return -ENOSPC; + if (rte_ring_sc_dequeue(h->free_slots, &slot_id) != 0) { + ret = -ENOSPC; + goto failure; + } } new_k = RTE_PTR_ADD(keys, (uintptr_t)slot_id * h->key_entry_size); @@ -659,6 +663,7 @@ struct rte_hash * /* Error in addition, store new slot back in the ring and return error */ enqueue_slot_back(h, cached_free_slots, (void *)((uintptr_t) new_idx)); +failure: if (h->add_key == ADD_KEY_MULTIWRITER) rte_spinlock_unlock(h->multiwriter_lock); return ret; -- 1.9.1