patches for DPDK stable branches
 help / color / Atom feed
* [dpdk-stable] [dpdk-dev] [PATCH v2 RESEND] vfio: fix resource leak when mapping fails
       [not found] <20200621090800.1AE521C00D@dpdk.org>
@ 2020-09-11 11:08 ` wangyunjian
  2020-09-17 10:35   ` Burakov, Anatoly
  0 siblings, 1 reply; 2+ messages in thread
From: wangyunjian @ 2020-09-11 11:08 UTC (permalink / raw)
  To: dev
  Cc: anatoly.burakov, ferruh.yigit, david.marchand, jerry.lilijun,
	xudingke, Yunjian Wang, stable

From: Yunjian Wang <wangyunjian@huawei.com>

Currently, only the 'vfio_dev_fd' is closed in failure path, so
some resources are not released(such as 'vfio_group_fd'). The
rte_vfio_release_device() should be used to avoid this problem.

Fixes: 33604c31354a ("vfio: refactor PCI BAR mapping")
Cc: stable@dpdk.org

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
v2:
   Update email address
---
 drivers/bus/pci/linux/pci_vfio.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c
index c15ed3bad..17350f34d 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -826,7 +826,8 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev)
 err_vfio_res:
 	rte_free(vfio_res);
 err_vfio_dev_fd:
-	close(vfio_dev_fd);
+	rte_vfio_release_device(rte_pci_get_sysfs_path(),
+			pci_addr, vfio_dev_fd);
 	return -1;
 }
 
@@ -894,7 +895,8 @@ pci_vfio_map_resource_secondary(struct rte_pci_device *dev)
 
 	return 0;
 err_vfio_dev_fd:
-	close(vfio_dev_fd);
+	rte_vfio_release_device(rte_pci_get_sysfs_path(),
+			pci_addr, vfio_dev_fd);
 	return -1;
 }
 
-- 
2.23.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-stable] [dpdk-dev] [PATCH v2 RESEND] vfio: fix resource leak when mapping fails
  2020-09-11 11:08 ` [dpdk-stable] [dpdk-dev] [PATCH v2 RESEND] vfio: fix resource leak when mapping fails wangyunjian
@ 2020-09-17 10:35   ` Burakov, Anatoly
  0 siblings, 0 replies; 2+ messages in thread
From: Burakov, Anatoly @ 2020-09-17 10:35 UTC (permalink / raw)
  To: wangyunjian, dev
  Cc: ferruh.yigit, david.marchand, jerry.lilijun, xudingke, stable

On 11-Sep-20 12:08 PM, wangyunjian wrote:
> From: Yunjian Wang <wangyunjian@huawei.com>
> 
> Currently, only the 'vfio_dev_fd' is closed in failure path, so
> some resources are not released(such as 'vfio_group_fd'). The
> rte_vfio_release_device() should be used to avoid this problem.
> 
> Fixes: 33604c31354a ("vfio: refactor PCI BAR mapping")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---

Reviewed-by: Anatoly Burakov <anatoly.burakov@intel.com>

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20200621090800.1AE521C00D@dpdk.org>
2020-09-11 11:08 ` [dpdk-stable] [dpdk-dev] [PATCH v2 RESEND] vfio: fix resource leak when mapping fails wangyunjian
2020-09-17 10:35   ` Burakov, Anatoly

patches for DPDK stable branches

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/ public-inbox