From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 6CF69A0096 for ; Wed, 8 May 2019 18:02:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 62314DE3; Wed, 8 May 2019 18:02:52 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id E3A36DE3 for ; Wed, 8 May 2019 18:02:50 +0200 (CEST) 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 5283C3007428; Wed, 8 May 2019 16:02:50 +0000 (UTC) Received: from rh.redhat.com (ovpn-117-210.ams2.redhat.com [10.36.117.210]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46E3E60C82; Wed, 8 May 2019 16:02:49 +0000 (UTC) From: Kevin Traynor To: Herakliusz Lipiec Cc: Anatoly Burakov , dpdk stable Date: Wed, 8 May 2019 17:02:06 +0100 Message-Id: <20190508160233.2648-9-ktraynor@redhat.com> In-Reply-To: <20190508160233.2648-1-ktraynor@redhat.com> References: <20190508160233.2648-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.43]); Wed, 08 May 2019 16:02:50 +0000 (UTC) Subject: [dpdk-stable] patch 'ipc: fix memory leak on request failure' has been queued to LTS release 18.11.2 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: , Errors-To: stable-bounces@dpdk.org Sender: "stable" Hi, FYI, your patch has been queued to LTS release 18.11.2 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 05/14/19. 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. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/kevintraynor/dpdk-stable-queue This queued commit can be viewed at: https://github.com/kevintraynor/dpdk-stable-queue/commit/ae62bad432359db3c5a499041d4c18cd0476a141 Thanks. Kevin Traynor --- >From ae62bad432359db3c5a499041d4c18cd0476a141 Mon Sep 17 00:00:00 2001 From: Herakliusz Lipiec Date: Thu, 25 Apr 2019 13:48:16 +0100 Subject: [PATCH] ipc: fix memory leak on request failure [ upstream commit a2a06860b8c4cb4460044fa40c867fa2e908035d ] When sending multiple requests, rte_mp_request_sync can succeed sending a few of those requests, but then fail on a later one and in the end return with rc=-1. The upper layers - e.g. device hotplug - currently handles this case as if no messages were sent and no memory for response buffers was allocated, which is not true. Fixed by always freeing memory buffers on failure. Bugzilla ID: 228 Fixes: 783b6e54971d ("eal: add synchronous multi-process communication") Signed-off-by: Herakliusz Lipiec Reviewed-by: Anatoly Burakov --- lib/librte_eal/common/eal_common_proc.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c index b46d644b3..ef5eddbea 100644 --- a/lib/librte_eal/common/eal_common_proc.c +++ b/lib/librte_eal/common/eal_common_proc.c @@ -928,11 +928,11 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, RTE_LOG(DEBUG, EAL, "request: %s\n", req->name); - if (check_input(req) == false) - return -1; - reply->nb_sent = 0; reply->nb_received = 0; reply->msgs = NULL; + if (check_input(req) == false) + goto err; + if (internal_config.no_shconf) { RTE_LOG(DEBUG, EAL, "No shared files mode enabled, IPC is disabled\n"); @@ -943,5 +943,5 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, RTE_LOG(ERR, EAL, "Failed to get current time\n"); rte_errno = errno; - return -1; + goto err; } @@ -955,4 +955,6 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, ret = mp_request_sync(eal_mp_socket_path(), req, reply, &end); pthread_mutex_unlock(&pending_requests.lock); + if (ret) + goto err; return ret; } @@ -963,5 +965,5 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, RTE_LOG(ERR, EAL, "Unable to open directory %s\n", mp_dir_path); rte_errno = errno; - return -1; + goto err; } @@ -973,5 +975,5 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, closedir(mp_dir); rte_errno = errno; - return -1; + goto err; } @@ -990,5 +992,5 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, */ if (mp_request_sync(path, req, reply, &end)) - ret = -1; + goto err; } pthread_mutex_unlock(&pending_requests.lock); @@ -999,4 +1001,10 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, closedir(mp_dir); return ret; + +err: + free(reply->msgs); + reply->nb_received = 0; + reply->msgs = NULL; + return -1; } -- 2.20.1 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2019-05-08 16:33:57.953289339 +0100 +++ 0009-ipc-fix-memory-leak-on-request-failure.patch 2019-05-08 16:33:57.362579749 +0100 @@ -1 +1 @@ -From a2a06860b8c4cb4460044fa40c867fa2e908035d Mon Sep 17 00:00:00 2001 +From ae62bad432359db3c5a499041d4c18cd0476a141 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit a2a06860b8c4cb4460044fa40c867fa2e908035d ] + @@ -17 +18,0 @@ -Cc: stable@dpdk.org