From patchwork Wed Apr 17 14:38:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herakliusz Lipiec X-Patchwork-Id: 52868 X-Patchwork-Delegate: thomas@monjalon.net 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 2CA221B6B6; Wed, 17 Apr 2019 16:37:41 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 203621B69B; Wed, 17 Apr 2019 16:37:38 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2019 07:37:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,362,1549958400"; d="scan'208";a="136586665" Received: from silpixa00399499.ir.intel.com (HELO silpixa00399499.ger.corp.intel.com) ([10.237.222.133]) by orsmga006.jf.intel.com with ESMTP; 17 Apr 2019 07:37:36 -0700 From: Herakliusz Lipiec To: dev@dpdk.org Cc: Herakliusz Lipiec , jianfeng.tan@intel.com, jia.quo@intel.com, gi.z.zhang@intel.com, stable@dpdk.org Date: Wed, 17 Apr 2019 15:38:22 +0100 Message-Id: <20190417143822.21276-1-herakliusz.lipiec@intel.com> X-Mailer: git-send-email 2.17.2 Subject: [dpdk-dev] [PATCH 1/8] 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 initializing message buffer to NULL. Fixes: 783b6e54971d ("eal: add synchronous multi-process communication") Cc: jianfeng.tan@intel.com Cc: jia.quo@intel.com Cc: gi.z.zhang@intel.com Cc: stable@dpdk.org Signed-off-by: Herakliusz Lipiec Acked-by: Anatoly Burakov --- lib/librte_eal/common/eal_common_proc.c | 6 +++--- lib/librte_eal/common/include/rte_eal.h | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c index b46d644b3..abaff5164 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) + return -1; + if (internal_config.no_shconf) { RTE_LOG(DEBUG, EAL, "No shared files mode enabled, IPC is disabled\n"); return 0; diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h index 833433229..575f8119e 100644 --- a/lib/librte_eal/common/include/rte_eal.h +++ b/lib/librte_eal/common/include/rte_eal.h @@ -309,7 +309,8 @@ rte_mp_sendmsg(struct rte_mp_msg *msg); * This function sends a request message to the peer process, and will * block until receiving reply message from the peer process. * - * @note The caller is responsible to free reply->replies. + * @note The caller is responsible to free reply->replies (even if the function + * returned failure). * * @param req * The req argument contains the customized request message. From patchwork Wed Apr 17 14:38:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herakliusz Lipiec X-Patchwork-Id: 52869 X-Patchwork-Delegate: thomas@monjalon.net 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 A06681B6DC; Wed, 17 Apr 2019 16:37:52 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 16DD51B69B; Wed, 17 Apr 2019 16:37:49 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2019 07:37:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,362,1549958400"; d="scan'208";a="135134647" Received: from silpixa00399499.ir.intel.com (HELO silpixa00399499.ger.corp.intel.com) ([10.237.222.133]) by orsmga008.jf.intel.com with ESMTP; 17 Apr 2019 07:37:47 -0700 From: Herakliusz Lipiec To: dev@dpdk.org Cc: Herakliusz Lipiec , qi.z.zhang@intel.com, stable@dpdk.org Date: Wed, 17 Apr 2019 15:38:41 +0100 Message-Id: <20190417143841.21404-1-herakliusz.lipiec@intel.com> X-Mailer: git-send-email 2.17.2 Subject: [dpdk-dev] [PATCH 2/8] ipc: fix hotplug 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 the buffers. Fixes: ac9e4a17370f ("eal: support attach/detach shared device from secondary") Cc: qi.z.zhang@intel.com Cc: stable@dpdk.org Signed-off-by: Herakliusz Lipiec --- lib/librte_eal/common/hotplug_mp.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/librte_eal/common/hotplug_mp.c b/lib/librte_eal/common/hotplug_mp.c index 4052a5c7f..2c8366afa 100644 --- a/lib/librte_eal/common/hotplug_mp.c +++ b/lib/librte_eal/common/hotplug_mp.c @@ -377,6 +377,7 @@ int eal_dev_hotplug_request_to_primary(struct eal_dev_mp_req *req) ret = rte_mp_request_sync(&mp_req, &mp_reply, &ts); if (ret || mp_reply.nb_received != 1) { RTE_LOG(ERR, EAL, "cannot send request to primary"); + free(mp_reply.msgs); if (!ret) return -1; return ret; @@ -405,6 +406,7 @@ int eal_dev_hotplug_request_to_secondary(struct eal_dev_mp_req *req) ret = rte_mp_request_sync(&mp_req, &mp_reply, &ts); if (ret != 0) { RTE_LOG(ERR, EAL, "rte_mp_request_sync failed\n"); + free(mp_reply.msgs); return ret; } From patchwork Wed Apr 17 14:38:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herakliusz Lipiec X-Patchwork-Id: 52870 X-Patchwork-Delegate: thomas@monjalon.net 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 C74A91B6DB; Wed, 17 Apr 2019 16:38:04 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id DAB301B6CD; Wed, 17 Apr 2019 16:38:02 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga102.jf.intel.com with ESMTP; 17 Apr 2019 07:38:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,362,1549958400"; d="scan'208";a="338355620" Received: from silpixa00399499.ir.intel.com (HELO silpixa00399499.ger.corp.intel.com) ([10.237.222.133]) by fmsmga006.fm.intel.com with ESMTP; 17 Apr 2019 07:38:00 -0700 From: Herakliusz Lipiec To: dev@dpdk.org Cc: Herakliusz Lipiec , jianfeng.tan@intel.com, stable@dpdk.org Date: Wed, 17 Apr 2019 15:38:54 +0100 Message-Id: <20190417143854.21588-1-herakliusz.lipiec@intel.com> X-Mailer: git-send-email 2.17.2 Subject: [dpdk-dev] [PATCH 3/8] ipc: fix vdev 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 the reply message buffers. Fixes: cdb068f031c6 ("bus/vdev: scan by multi-process channel") Cc: jianfeng.tan@intel.com Cc: stable@dpdk.org Signed-off-by: Herakliusz Lipiec --- drivers/bus/vdev/vdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index 04f76a63f..7c43f2ddd 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -429,10 +429,9 @@ vdev_scan(void) mp_rep = &mp_reply.msgs[0]; resp = (struct vdev_param *)mp_rep->param; VDEV_LOG(INFO, "Received %d vdevs", resp->num); - free(mp_reply.msgs); } else VDEV_LOG(ERR, "Failed to request vdev from primary"); - + free(mp_reply.msgs); /* Fall through to allow private vdevs in secondary process */ } From patchwork Wed Apr 17 14:41:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herakliusz Lipiec X-Patchwork-Id: 52871 X-Patchwork-Delegate: thomas@monjalon.net 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 A12E41B6BC; Wed, 17 Apr 2019 16:40:18 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id A0837397D; Wed, 17 Apr 2019 16:40:16 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2019 07:40:15 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,362,1549958400"; d="scan'208";a="151650300" Received: from silpixa00399499.ir.intel.com (HELO silpixa00399499.ger.corp.intel.com) ([10.237.222.133]) by orsmga002.jf.intel.com with ESMTP; 17 Apr 2019 07:40:14 -0700 From: Herakliusz Lipiec To: anatoly.burakov@intel.com Cc: dev@dpdk.org, Herakliusz Lipiec , jianfeng.tan@intel.com, stable@dpdk.org Date: Wed, 17 Apr 2019 15:41:00 +0100 Message-Id: <20190417144100.22548-1-herakliusz.lipiec@intel.com> X-Mailer: git-send-email 2.17.2 Subject: [dpdk-dev] [PATCH 4/8] ipc: fix vfio 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 reply message buffers. Fixes: 83a73c5fef66 ("vfio: use generic multi-process channel") Cc: jianfeng.tan@intel.com Cc: stable@dpdk.org Signed-off-by: Herakliusz Lipiec Acked-by: Anatoly Burakov --- lib/librte_eal/linux/eal/eal_vfio.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c index 19e70bb66..d293df062 100644 --- a/lib/librte_eal/linux/eal/eal_vfio.c +++ b/lib/librte_eal/linux/eal/eal_vfio.c @@ -319,8 +319,8 @@ vfio_open_group_fd(int iommu_group_num) RTE_LOG(ERR, EAL, " bad VFIO group fd\n"); vfio_group_fd = 0; } - free(mp_reply.msgs); } + free(mp_reply.msgs); if (vfio_group_fd < 0) RTE_LOG(ERR, EAL, " cannot request group fd\n"); @@ -583,8 +583,8 @@ vfio_sync_default_container(void) p = (struct vfio_mp_param *)mp_rep->param; if (p->result == SOCKET_OK) iommu_type_id = p->iommu_type_id; - free(mp_reply.msgs); } + free(mp_reply.msgs); if (iommu_type_id < 0) { RTE_LOG(ERR, EAL, "Could not get IOMMU type for default container\n"); return -1; @@ -1050,8 +1050,8 @@ vfio_get_default_container_fd(void) free(mp_reply.msgs); return mp_rep->fds[0]; } - free(mp_reply.msgs); } + free(mp_reply.msgs); RTE_LOG(ERR, EAL, " cannot request default container fd\n"); return -1; @@ -1182,8 +1182,8 @@ rte_vfio_get_container_fd(void) free(mp_reply.msgs); return vfio_container_fd; } - free(mp_reply.msgs); } + free(mp_reply.msgs); RTE_LOG(ERR, EAL, " cannot request container fd\n"); return -1; From patchwork Wed Apr 17 14:41:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herakliusz Lipiec X-Patchwork-Id: 52872 X-Patchwork-Delegate: thomas@monjalon.net 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 38F771B6E2; Wed, 17 Apr 2019 16:41:12 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 420091B6B6; Wed, 17 Apr 2019 16:41:10 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2019 07:41:09 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,362,1549958400"; d="scan'208";a="316748507" Received: from silpixa00399499.ir.intel.com (HELO silpixa00399499.ger.corp.intel.com) ([10.237.222.133]) by orsmga005.jf.intel.com with ESMTP; 17 Apr 2019 07:41:07 -0700 From: Herakliusz Lipiec To: reshma.pattan@intel.com Cc: dev@dpdk.org, Herakliusz Lipiec , jianfeng.tan@intel.com, stable@dpdk.org Date: Wed, 17 Apr 2019 15:41:58 +0100 Message-Id: <20190417144158.23016-1-herakliusz.lipiec@intel.com> X-Mailer: git-send-email 2.17.2 Subject: [dpdk-dev] [PATCH 5/8] ipc: fix pdump 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 reply message buffers. Fixes: 660098d61f57 ("pdump: use generic multi-process channel") Cc: jianfeng.tan@intel.com Cc: stable@dpdk.org Signed-off-by: Herakliusz Lipiec Acked-By: Reshma Pattan --- lib/librte_pdump/rte_pdump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/librte_pdump/rte_pdump.c b/lib/librte_pdump/rte_pdump.c index 14744b9ff..3787c3e32 100644 --- a/lib/librte_pdump/rte_pdump.c +++ b/lib/librte_pdump/rte_pdump.c @@ -525,8 +525,8 @@ pdump_prepare_client_request(char *device, uint16_t queue, rte_errno = resp->err_value; if (!resp->err_value) ret = 0; - free(mp_reply.msgs); } + free(mp_reply.msgs); if (ret < 0) RTE_LOG(ERR, PDUMP, From patchwork Wed Apr 17 14:42:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herakliusz Lipiec X-Patchwork-Id: 52873 X-Patchwork-Delegate: thomas@monjalon.net 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 930181B6E2; Wed, 17 Apr 2019 16:41:57 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 65AC5397D; Wed, 17 Apr 2019 16:41:55 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Apr 2019 07:41:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,362,1549958400"; d="scan'208";a="135135756" Received: from silpixa00399499.ir.intel.com (HELO silpixa00399499.ger.corp.intel.com) ([10.237.222.133]) by orsmga008.jf.intel.com with ESMTP; 17 Apr 2019 07:41:52 -0700 From: Herakliusz Lipiec To: keith.wiles@intel.com Cc: dev@dpdk.org, Herakliusz Lipiec , rasland@mellanox.com, stable@dpdk.org Date: Wed, 17 Apr 2019 15:42:45 +0100 Message-Id: <20190417144245.23353-1-herakliusz.lipiec@intel.com> X-Mailer: git-send-email 2.17.2 Subject: [dpdk-dev] [PATCH 6/8] 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 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 reply message buffers. 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, 2 insertions(+) diff --git a/drivers/net/tap/rte_eth_tap.c b/drivers/net/tap/rte_eth_tap.c index e9fda8cf6..d70412d62 100644 --- a/drivers/net/tap/rte_eth_tap.c +++ b/drivers/net/tap/rte_eth_tap.c @@ -2104,6 +2104,7 @@ tap_mp_attach_queues(const char *port_name, struct rte_eth_dev *dev) if (ret < 0) { TAP_LOG(ERR, "Failed to request queues from primary: %d", rte_errno); + free(replies.msgs); return -1; } reply = &replies.msgs[0]; @@ -2119,6 +2120,7 @@ tap_mp_attach_queues(const char *port_name, struct rte_eth_dev *dev) for (queue = 0; queue < reply_param->txq_count; queue++) process_private->txq_fds[queue] = reply->fds[fd_iterator++]; + free(replies.msgs); return 0; } From patchwork Wed Apr 17 14:43:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herakliusz Lipiec X-Patchwork-Id: 52875 X-Patchwork-Delegate: thomas@monjalon.net 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 C6DF21B706; Wed, 17 Apr 2019 16:43:07 +0200 (CEST) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 1DF181B6C8 for ; Wed, 17 Apr 2019 16:43:06 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP; 17 Apr 2019 07:43:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,362,1549958400"; d="scan'208";a="338356913" Received: from silpixa00399499.ir.intel.com (HELO silpixa00399499.ger.corp.intel.com) ([10.237.222.133]) by fmsmga006.fm.intel.com with ESMTP; 17 Apr 2019 07:43:05 -0700 From: Herakliusz Lipiec To: matan@mellanox.com, shahafs@mellanox.com Cc: dev@dpdk.org, Herakliusz Lipiec , yskoh@mellanox.com Date: Wed, 17 Apr 2019 15:43:58 +0100 Message-Id: <20190417144358.23888-1-herakliusz.lipiec@intel.com> X-Mailer: git-send-email 2.17.2 Subject: [dpdk-dev] [PATCH 7/8] ipc: fix net/mlx4 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 reply message buffers. Fixes: 0b259b8e9655 ("net/mlx4: enable secondary process to register DMA memory") Cc: yskoh@mellanox.com Signed-off-by: Herakliusz Lipiec --- drivers/net/mlx4/mlx4_mp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx4/mlx4_mp.c b/drivers/net/mlx4/mlx4_mp.c index 183622453..f4cff7486 100644 --- a/drivers/net/mlx4/mlx4_mp.c +++ b/drivers/net/mlx4/mlx4_mp.c @@ -255,6 +255,7 @@ mlx4_mp_req_mr_create(struct rte_eth_dev *dev, uintptr_t addr) if (ret) { ERROR("port %u request to primary process failed", dev->data->port_id); + free(mp_rep.msgs); return -rte_errno; } assert(mp_rep.nb_received == 1); @@ -292,7 +293,8 @@ mlx4_mp_req_verbs_cmd_fd(struct rte_eth_dev *dev) if (ret) { ERROR("port %u request to primary process failed", dev->data->port_id); - return -rte_errno; + ret = -rte_errno; + goto exit; } assert(mp_rep.nb_received == 1); mp_res = &mp_rep.msgs[0]; From patchwork Wed Apr 17 14:44:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herakliusz Lipiec X-Patchwork-Id: 52876 X-Patchwork-Delegate: thomas@monjalon.net 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 E0D695F2C; Wed, 17 Apr 2019 16:43:46 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 58CC544C3 for ; Wed, 17 Apr 2019 16:43:45 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga101.fm.intel.com with ESMTP; 17 Apr 2019 07:43:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,362,1549958400"; d="scan'208";a="141464411" Received: from silpixa00399499.ir.intel.com (HELO silpixa00399499.ger.corp.intel.com) ([10.237.222.133]) by fmsmga008.fm.intel.com with ESMTP; 17 Apr 2019 07:43:42 -0700 From: Herakliusz Lipiec To: shafafs@mellanox.com Cc: dev@dpdk.org, Herakliusz Lipiec , yskoh@mellanox.com Date: Wed, 17 Apr 2019 15:44:36 +0100 Message-Id: <20190417144436.24216-1-herakliusz.lipiec@intel.com> X-Mailer: git-send-email 2.17.2 Subject: [dpdk-dev] [PATCH 8/8] ipc: fix net/mlx5 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 reply message buffers. Fixes: 9a8ab29b84d3 ("net/mlx5: replace IPC socket with EAL API") Fixes: c18cf501a7af ("net/mlx5: enable secondary process to register DMA memory") Cc: yskoh@mellanox.com Signed-off-by: Herakliusz Lipiec --- drivers/net/mlx5/mlx5_mp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_mp.c b/drivers/net/mlx5/mlx5_mp.c index cea74adb6..c9915b1d5 100644 --- a/drivers/net/mlx5/mlx5_mp.c +++ b/drivers/net/mlx5/mlx5_mp.c @@ -258,6 +258,7 @@ mlx5_mp_req_mr_create(struct rte_eth_dev *dev, uintptr_t addr) if (ret) { DRV_LOG(ERR, "port %u request to primary process failed", dev->data->port_id); + free(mp_rep.msgs); return -rte_errno; } assert(mp_rep.nb_received == 1); @@ -295,7 +296,8 @@ mlx5_mp_req_verbs_cmd_fd(struct rte_eth_dev *dev) if (ret) { DRV_LOG(ERR, "port %u request to primary process failed", dev->data->port_id); - return -rte_errno; + ret = -rte_errno; + goto exit; } assert(mp_rep.nb_received == 1); mp_res = &mp_rep.msgs[0];