From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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: , X-List-Received-Date: Wed, 17 Apr 2019 14:40:17 -0000 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 --- 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; -- 2.17.2 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 198F8A00E6 for ; Wed, 17 Apr 2019 16:40:19 +0200 (CEST) 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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190417144100.xU44Bsv-tW0SZqv6XkemwgayiVFIA_JBp7mdt3Rmmsk@z> 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 --- 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; -- 2.17.2