From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id A17381B488 for ; Thu, 22 Nov 2018 17:51:56 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1301388E51; Thu, 22 Nov 2018 16:51:56 +0000 (UTC) Received: from ktraynor.remote.csb (unknown [10.36.118.7]) by smtp.corp.redhat.com (Postfix) with ESMTP id EC1CE60FD9; Thu, 22 Nov 2018 16:51:54 +0000 (UTC) From: Kevin Traynor To: Anatoly Burakov Cc: dpdk stable Date: Thu, 22 Nov 2018 16:49:11 +0000 Message-Id: <20181122164957.13003-19-ktraynor@redhat.com> In-Reply-To: <20181122164957.13003-1-ktraynor@redhat.com> References: <20181122164957.13003-1-ktraynor@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 22 Nov 2018 16:51:56 +0000 (UTC) Subject: [dpdk-stable] patch 'mem: fix resource leak' has been queued to stable release 18.08.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: Thu, 22 Nov 2018 16:51:57 -0000 Hi, FYI, your patch has been queued to stable release 18.08.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 11/28/18. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. If the code is different (ie: not only metadata diffs), due for example to a change in context or macro names, please double check it. Thanks. Kevin Traynor --- >>From 1c80e6f838c2bdba592583259449b978c64ae778 Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Mon, 22 Oct 2018 13:57:03 +0100 Subject: [PATCH] mem: fix resource leak [ upstream commit 198b66b9461c01558d4fb474d1485d1312bf2650 ] Segment preallocation code allocates an array of structures on the heap but does not free the memory afterwards. Fix it by freeing it at the end of the function, and changing control flow to always go through that code path. Coverity issue: 323524 Fixes: 1dd342d0fdc4 ("mem: improve segment list preallocation") Signed-off-by: Anatoly Burakov --- lib/librte_eal/linuxapp/eal/eal_memory.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c index cc2d3fb69..f442dd5ec 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c @@ -2100,5 +2100,5 @@ memseg_primary_init(void) int socket_id; } *memtypes = NULL; - int i, hpi_idx, msl_idx; + int i, hpi_idx, msl_idx, ret = -1; /* fail unless told to succeed */ struct rte_memseg_list *msl; uint64_t max_mem, max_mem_per_type; @@ -2192,5 +2192,5 @@ memseg_primary_init(void) RTE_LOG(ERR, EAL, "Cannot accommodate all memory types, please increase %s\n", RTE_STR(CONFIG_RTE_MAX_MEMSEG_LISTS)); - return -1; + goto out; } @@ -2252,5 +2252,5 @@ memseg_primary_init(void) "No more space in memseg lists, please increase %s\n", RTE_STR(CONFIG_RTE_MAX_MEMSEG_LISTS)); - return -1; + goto out; } msl = &mcfg->memsegs[msl_idx++]; @@ -2258,13 +2258,17 @@ memseg_primary_init(void) if (alloc_memseg_list(msl, pagesz, n_segs, socket_id, cur_seglist)) - return -1; + goto out; if (alloc_va_space(msl)) { RTE_LOG(ERR, EAL, "Cannot allocate VA space for memseg list\n"); - return -1; + goto out; } } } - return 0; + /* we're successful */ + ret = 0; +out: + free(memtypes); + return ret; } -- 2.19.0 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2018-11-22 16:47:32.765993431 +0000 +++ 0019-mem-fix-resource-leak.patch 2018-11-22 16:47:32.000000000 +0000 @@ -1,8 +1,10 @@ -From 198b66b9461c01558d4fb474d1485d1312bf2650 Mon Sep 17 00:00:00 2001 +From 1c80e6f838c2bdba592583259449b978c64ae778 Mon Sep 17 00:00:00 2001 From: Anatoly Burakov Date: Mon, 22 Oct 2018 13:57:03 +0100 Subject: [PATCH] mem: fix resource leak +[ upstream commit 198b66b9461c01558d4fb474d1485d1312bf2650 ] + Segment preallocation code allocates an array of structures on the heap but does not free the memory afterwards. Fix it by freeing it at the end of the function, and changing control flow to always go @@ -10,7 +12,6 @@ Coverity issue: 323524 Fixes: 1dd342d0fdc4 ("mem: improve segment list preallocation") -Cc: stable@dpdk.org Signed-off-by: Anatoly Burakov --- @@ -18,31 +19,31 @@ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/linuxapp/eal/eal_memory.c -index 19e686eb6..fce86fda6 100644 +index cc2d3fb69..f442dd5ec 100644 --- a/lib/librte_eal/linuxapp/eal/eal_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c -@@ -2136,5 +2136,5 @@ memseg_primary_init(void) +@@ -2100,5 +2100,5 @@ memseg_primary_init(void) int socket_id; } *memtypes = NULL; - int i, hpi_idx, msl_idx; + int i, hpi_idx, msl_idx, ret = -1; /* fail unless told to succeed */ struct rte_memseg_list *msl; uint64_t max_mem, max_mem_per_type; -@@ -2228,5 +2228,5 @@ memseg_primary_init(void) +@@ -2192,5 +2192,5 @@ memseg_primary_init(void) RTE_LOG(ERR, EAL, "Cannot accommodate all memory types, please increase %s\n", RTE_STR(CONFIG_RTE_MAX_MEMSEG_LISTS)); - return -1; + goto out; } -@@ -2288,5 +2288,5 @@ memseg_primary_init(void) +@@ -2252,5 +2252,5 @@ memseg_primary_init(void) "No more space in memseg lists, please increase %s\n", RTE_STR(CONFIG_RTE_MAX_MEMSEG_LISTS)); - return -1; + goto out; } msl = &mcfg->memsegs[msl_idx++]; -@@ -2294,13 +2294,17 @@ memseg_primary_init(void) +@@ -2258,13 +2258,17 @@ memseg_primary_init(void) if (alloc_memseg_list(msl, pagesz, n_segs, socket_id, cur_seglist)) - return -1;