From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id F05C21B799 for ; Wed, 7 Feb 2018 10:00:14 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id A78A620F5F; Wed, 7 Feb 2018 04:00:14 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Wed, 07 Feb 2018 04:00:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:date:from:in-reply-to:message-id:references:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=RbVZOAwOm8v6SQbSp oEnoX5Ipjk5GVBpl2Yi5AMV+PI=; b=voCk5FoRO+NIOlVwCH/JAhG5w03KgShJv NNMifmqIsXSqaSnUsrK8eSA5Mtfs1k9zCUxTGKWEGDcmW5HOBalEc5zUx2yFZJtD yRK2Y6a3QwUqTlbxEnCdN6+E5PkHvb2DWoXTDtKjWvuVYt3ZMSiGhY+Bj11fRLXx 6QISfRYVR/GtT6D3wlkVnVcaA0/LHj/GW46QmG5NJDq+TQwdNcy5JSKd6edK7q8m XjYXGisQUblv6cJ3dZDA+NGfngvs9rFOGRbT5Ga3qQmcaftznuwZZXClFnM3a3H2 Ivuim/UdgFSXzXoNjs2VdiBo5BfiWqalVS+9Kqmx4JhjVxX4Z8S1A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=RbVZOAwOm8v6SQbSpoEnoX5Ipjk5GVBpl2Yi5AMV+PI=; b=jJU+oJEU WOM3k8eSBFkN3uwxC5bvceAQkcDCvFQHEymGDpXMpuJKPyzPCyISidlgjrKQv+Ge 7fMEZSxyausqqY7cbYs82UIU/MyuruJiRhIybOnm3XfnscPMSrqaNTYOSZmeJGKZ jtoQu6J3CwcvHOMbvsztsbpJXXboApOoujDNCZ9OhCHllSHarJmmPz1zVrYi0Nm0 eBul5+Qq+1RyfSmY56aL1MO4Kib88ClLBRmRCZjyRS17v+0MRG1sF/dpyi3zs/9/ 4Hqcq1x1lqB8PyhYebciMlpYtjCs2gHYWhsU7Mkm/yDRbQLfbqKt/I9heq2FQ+gB He3TydytaS53qg== X-ME-Sender: Received: from localhost.localdomain (unknown [182.84.161.100]) by mail.messagingengine.com (Postfix) with ESMTPA id 7306224636; Wed, 7 Feb 2018 04:00:12 -0500 (EST) From: Yuanhan Liu To: Anatoly Burakov Cc: Olivier Matz , dpdk stable Date: Wed, 7 Feb 2018 16:57:14 +0800 Message-Id: <1517993838-26692-20-git-send-email-yliu@fridaylinux.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1517993838-26692-1-git-send-email-yliu@fridaylinux.org> References: <1517993838-26692-1-git-send-email-yliu@fridaylinux.org> Subject: [dpdk-stable] patch 'test/ring: fix memory leak' has been queued to LTS release 17.11.1 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: Wed, 07 Feb 2018 09:00:15 -0000 Hi, FYI, your patch has been queued to LTS release 17.11.1 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 02/09/18. So please shout if anyone has objections. Thanks. --yliu --- >>From 3fb4d531c82a99eae9ef0121cb8b1e85b8bbe4ee Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Tue, 6 Feb 2018 13:35:39 +0000 Subject: [PATCH] test/ring: fix memory leak [ upstream commit 14ec04e1ae0f55c68d2c718e3a6cf9e6b6adeac4 ] Get rid of global static ring variable and don't reuse rings between test runs. Acked-by: Olivier Matz Fixes: 4e32101f9b01 ("ring: support freeing") Signed-off-by: Anatoly Burakov --- test/test/test_ring.c | 63 +++++++++++++++++++++++++++------------------------ 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/test/test/test_ring.c b/test/test/test_ring.c index 5eb40a0..d225e82 100644 --- a/test/test/test_ring.c +++ b/test/test/test_ring.c @@ -86,8 +86,6 @@ static rte_atomic32_t synchro; -static struct rte_ring *r; - #define TEST_RING_VERIFY(exp) \ if (!(exp)) { \ printf("error at %s:%d\tcondition " #exp " failed\n", \ @@ -102,7 +100,7 @@ static struct rte_ring *r; * helper routine for test_ring_basic */ static int -test_ring_basic_full_empty(void * const src[], void *dst[]) +test_ring_basic_full_empty(struct rte_ring *r, void * const src[], void *dst[]) { unsigned i, rand; const unsigned rsz = RING_SIZE - 1; @@ -143,7 +141,7 @@ test_ring_basic_full_empty(void * const src[], void *dst[]) } static int -test_ring_basic(void) +test_ring_basic(struct rte_ring *r) { void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL; int ret; @@ -279,7 +277,7 @@ test_ring_basic(void) goto fail; } - if (test_ring_basic_full_empty(src, dst) != 0) + if (test_ring_basic_full_empty(r, src, dst) != 0) goto fail; cur_src = src; @@ -346,7 +344,7 @@ test_ring_basic(void) } static int -test_ring_burst_basic(void) +test_ring_burst_basic(struct rte_ring *r) { void **src = NULL, **cur_src = NULL, **dst = NULL, **cur_dst = NULL; int ret; @@ -700,7 +698,7 @@ test_ring_basic_ex(void) { int ret = -1; unsigned i; - struct rte_ring * rp; + struct rte_ring *rp = NULL; void **obj = NULL; obj = rte_calloc("test_ring_basic_ex_malloc", RING_SIZE, sizeof(void *), 0); @@ -760,6 +758,7 @@ test_ring_basic_ex(void) ret = 0; fail_test: + rte_ring_free(rp); if (obj != NULL) rte_free(obj); @@ -840,61 +839,67 @@ end: static int test_ring(void) { + struct rte_ring *r = NULL; + /* some more basic operations */ if (test_ring_basic_ex() < 0) - return -1; + goto test_fail; rte_atomic32_init(&synchro); + r = rte_ring_create("test", RING_SIZE, SOCKET_ID_ANY, 0); if (r == NULL) - r = rte_ring_create("test", RING_SIZE, SOCKET_ID_ANY, 0); - if (r == NULL) - return -1; + goto test_fail; /* retrieve the ring from its name */ if (rte_ring_lookup("test") != r) { printf("Cannot lookup ring from its name\n"); - return -1; + goto test_fail; } /* burst operations */ - if (test_ring_burst_basic() < 0) - return -1; + if (test_ring_burst_basic(r) < 0) + goto test_fail; /* basic operations */ - if (test_ring_basic() < 0) - return -1; + if (test_ring_basic(r) < 0) + goto test_fail; /* basic operations */ if ( test_create_count_odd() < 0){ - printf ("Test failed to detect odd count\n"); - return -1; - } - else - printf ( "Test detected odd count\n"); + printf("Test failed to detect odd count\n"); + goto test_fail; + } else + printf("Test detected odd count\n"); if ( test_lookup_null() < 0){ - printf ("Test failed to detect NULL ring lookup\n"); - return -1; - } - else - printf ( "Test detected NULL ring lookup \n"); + printf("Test failed to detect NULL ring lookup\n"); + goto test_fail; + } else + printf("Test detected NULL ring lookup\n"); /* test of creating ring with wrong size */ if (test_ring_creation_with_wrong_size() < 0) - return -1; + goto test_fail; /* test of creation ring with an used name */ if (test_ring_creation_with_an_used_name() < 0) - return -1; + goto test_fail; if (test_ring_with_exact_size() < 0) - return -1; + goto test_fail; /* dump the ring status */ rte_ring_list_dump(stdout); + rte_ring_free(r); + return 0; + +test_fail: + rte_ring_free(r); + + return -1; } REGISTER_TEST_COMMAND(ring_autotest, test_ring); -- 2.7.4