From patchwork Thu Apr 25 11:43:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herakliusz Lipiec X-Patchwork-Id: 53070 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1D9641B589; Thu, 25 Apr 2019 13:42:36 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id D9DA31B567; Thu, 25 Apr 2019 13:42:30 +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 fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Apr 2019 04:42:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,393,1549958400"; d="scan'208";a="152266754" Received: from silpixa00399499.ir.intel.com (HELO silpixa00399499.ger.corp.intel.com) ([10.237.222.133]) by FMSMGA003.fm.intel.com with ESMTP; 25 Apr 2019 04:42:29 -0700 From: Herakliusz Lipiec To: Cc: dev@dpdk.org, anatoly.burakov@intel.com, Herakliusz Lipiec , jianfeng.tan@intel.com, stable@dpdk.org Date: Thu, 25 Apr 2019 12:43:23 +0100 Message-Id: <20190425114324.611-2-herakliusz.lipiec@intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190425114324.611-1-herakliusz.lipiec@intel.com> References: <20190423174334.19612-1-herakliusz.lipiec@intel.com> <20190425114324.611-1-herakliusz.lipiec@intel.com> Subject: [dpdk-dev] [PATCH v3 1/2] ipc: fix rte_mp_request_sync memleak 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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") Cc: jianfeng.tan@intel.com Cc: stable@dpdk.org 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 @@ -927,13 +927,13 @@ 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"); return 0; @@ -942,7 +942,7 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, if (gettimeofday(&now, NULL) < 0) { RTE_LOG(ERR, EAL, "Failed to get current time\n"); rte_errno = errno; - return -1; + goto err; } end.tv_nsec = (now.tv_usec * 1000 + ts->tv_nsec) % 1000000000; @@ -954,6 +954,8 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, pthread_mutex_lock(&pending_requests.lock); ret = mp_request_sync(eal_mp_socket_path(), req, reply, &end); pthread_mutex_unlock(&pending_requests.lock); + if (ret) + goto err; return ret; } @@ -962,7 +964,7 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, if (!mp_dir) { RTE_LOG(ERR, EAL, "Unable to open directory %s\n", mp_dir_path); rte_errno = errno; - return -1; + goto err; } dir_fd = dirfd(mp_dir); @@ -972,7 +974,7 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, mp_dir_path); closedir(mp_dir); rte_errno = errno; - return -1; + goto err; } pthread_mutex_lock(&pending_requests.lock); @@ -989,7 +991,7 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, * locks on receive */ if (mp_request_sync(path, req, reply, &end)) - ret = -1; + goto err; } pthread_mutex_unlock(&pending_requests.lock); /* unlock the directory */ @@ -998,6 +1000,12 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply, /* dir_fd automatically closed on closedir */ closedir(mp_dir); return ret; + +err: + free(reply->msgs); + reply->nb_received = 0; + reply->msgs = NULL; + return -1; } int __rte_experimental From patchwork Thu Apr 25 11:43:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herakliusz Lipiec X-Patchwork-Id: 53071 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C83081B590; Thu, 25 Apr 2019 13:42:40 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 4BDBE1B587; Thu, 25 Apr 2019 13:42:33 +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 fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Apr 2019 04:42:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,393,1549958400"; d="scan'208";a="152266759" Received: from silpixa00399499.ir.intel.com (HELO silpixa00399499.ger.corp.intel.com) ([10.237.222.133]) by FMSMGA003.fm.intel.com with ESMTP; 25 Apr 2019 04:42:31 -0700 From: Herakliusz Lipiec To: Keith Wiles Cc: dev@dpdk.org, anatoly.burakov@intel.com, Herakliusz Lipiec , rasland@mellanox.com, stable@dpdk.org Date: Thu, 25 Apr 2019 12:43:24 +0100 Message-Id: <20190425114324.611-3-herakliusz.lipiec@intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190425114324.611-1-herakliusz.lipiec@intel.com> References: <20190423174334.19612-1-herakliusz.lipiec@intel.com> <20190425114324.611-1-herakliusz.lipiec@intel.com> Subject: [dpdk-dev] [PATCH v3 2/2] ipc: fix tap pmd memleak 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When sending synchronous IPC requests, the caller must free the response buffer if the request was successful and reply is no longer needed. Fix the code to correctly use the IPC API. Bugzilla ID: 228 Fixes: c9aa56edec8e ("net/tap: access primary process queues from secondary") Cc: rasland@mellanox.com Cc: stable@dpdk.org Signed-off-by: Herakliusz Lipiec --- drivers/net/tap/rte_eth_tap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index 7f74b5dc9..3a74c2a43 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -2118,7 +2118,7 @@ tap_mp_attach_queues(const char *port_name, struct rte_eth_dev *dev) process_private->rxq_fds[queue] = reply->fds[fd_iterator++]; for (queue = 0; queue < reply_param->txq_count; queue++) process_private->txq_fds[queue] = reply->fds[fd_iterator++]; - + free(reply); return 0; }