From mboxrd@z Thu Jan 1 00:00:00 1970 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bigswitch-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=lredjTynucDECtsBuiKNIP5AFn2Q+hijML0uAlLqJdE=; b=QvQS7sUHVnPv1V9T4OAX4rCX7qLfjlLYZx4BceoZlIBs2gKxtF88yL6K01++scOGKC IEfzwEp7hL7NpybkvL8yEUvQ+Ic3VgFR0VGqsfFQ3f/axoUlKuZ6foJgUUu5EZxcuCQx sw3JEeMd2MnPModvdK4nqqbxs6DgFjytVaCjB11jrNbFXQazMGRdGNEkFcDmCmenTRfP xGywdJ4ypIiLM2x/3BwDuy6g07uTT2SvUpG3lQM5WHIJr4Td3l6SMD6t+AsnBvNurrwX Rl43TmiK0jk0rviuaoEqod4SbwjOMFT4EsJv0hybsMp9WTh9aELowhG/6uv4PL2IOgxw xdcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=lredjTynucDECtsBuiKNIP5AFn2Q+hijML0uAlLqJdE=; b=g5qjFBL5JPpN7mlTrYM9Z2mfmLap648AoB1k5hFWAq78Eu35FRpoEQhck4iO7m49D1 X4xgH2XUK1MmKen9dR1xwlEAhLpcHSQ2JKdQQqvITVHakuO6Qi4WV3PVRUK1wRuBKfNZ +rwUScw8G4Vsbyd22bsdtTQ2GcKwHAID6JI4CEWu0PCM6nm+q9NDmAO4C6T6U8Ywlr7J xdyMtVX6GrE8WgEFB3vkoa2OhKzY0sWfjV1clSE2sdmHEo1BM0+rZ+l93eLTdXr3hLJb RCitS1i3uT1+gUHtMFocRO1IoeoZCPytlUIk//pOkRRzCkNXckpuQyDGeNJfpObzaGPQ yI1w== X-Gm-Message-State: AODbwcCqZ8Ikk/OuPPc/dqwBwA39LwMWnD3e6AfgXQqDHL1HV0g+QHij rL1aBT7EqiFjSuqS9T/WXQ== X-Received: by 10.99.106.6 with SMTP id f6mr2151963pgc.168.1495801832933; Fri, 26 May 2017 05:30:32 -0700 (PDT) Received: from dpdk-dell-430.sw.bigswitch.com ([173.227.38.50]) by smtp.gmail.com with ESMTPSA id m8sm1605607pga.34.2017.05.26.05.30.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 26 May 2017 05:30:32 -0700 (PDT) From: mstolarchuk To: bruce.richardson@intel.co Cc: dev@dpdk.org Date: Fri, 26 May 2017 05:30:30 -0700 Message-Id: <1495801830-36849-1-git-send-email-mike.stolarchuk@bigswitch.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] __rte_hash_add_key_with_hash not releasing multiwriter_lock in failure paths X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 May 2017 12:30:34 -0000 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