From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 3EF761B449; Thu, 2 Aug 2018 10:36:15 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Aug 2018 01:36:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,434,1526367600"; d="scan'208";a="69452514" Received: from silpixa00399779.ir.intel.com ([10.237.223.187]) by FMSMGA003.fm.intel.com with ESMTP; 02 Aug 2018 01:36:13 -0700 From: Harry van Haaren To: dev@dpdk.org Cc: Harry van Haaren , bruce.richardson@intel.com, stable@dpdk.org, thomas@monjalon.net, jerin.jacob@caviumnetworks.com Date: Thu, 2 Aug 2018 09:36:04 +0100 Message-Id: <1533198964-30218-1-git-send-email-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-stable] [PATCH] event: fix check in ring_init() in event ring code X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Aug 2018 08:36:17 -0000 This commit fixes a bug in a 32-bit environment where the generic ring_init() would fail, but given the interaction with memzones the next iteration of the event_ring_autotest would actually *pass* because the ring in question would exist already an be looked-up. This commit rightly error checks the result of ring_init(), and calls rte_free() on the memory as required. Fixes: dc39e2f359b5 ("eventdev: add ring structure for events") Cc: bruce.richardson@intel.com Cc: stable@dpdk.org Signed-off-by: Harry van Haaren --- Cc: thomas@monjalon.net Cc: jerin.jacob@caviumnetworks.com Please consider this for RC3, as it fixes the unit tests on 32-bit systems. --- lib/librte_eventdev/rte_event_ring.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/librte_eventdev/rte_event_ring.c b/lib/librte_eventdev/rte_event_ring.c index eb67751..5791928 100644 --- a/lib/librte_eventdev/rte_event_ring.c +++ b/lib/librte_eventdev/rte_event_ring.c @@ -82,11 +82,14 @@ rte_event_ring_create(const char *name, unsigned int count, int socket_id, mz = rte_memzone_reserve(mz_name, ring_size, socket_id, mz_flags); if (mz != NULL) { r = mz->addr; - /* - * no need to check return value here, we already checked the - * arguments above - */ - rte_event_ring_init(r, name, requested_count, flags); + /* Check return value in case rte_ring_init() fails on size */ + int err = rte_event_ring_init(r, name, requested_count, flags); + if (err) { + RTE_LOG(ERR, RING, "Ring init failed\n"); + rte_free(te); + rte_rwlock_write_unlock(RTE_EAL_TAILQ_RWLOCK); + return 0; + } te->data = (void *) r; r->r.memzone = mz; -- 2.7.4