DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yunjian Wang <yunjian.wang@foxmail.com>
To: dev@dpdk.org, anatoly.burakov@intel.com
Cc: Yunjian Wang <yunjian.wang@foxmail.com>, stable@dpdk.org
Subject: [dpdk-dev]  [PATCH] vfio: fix resource leak when mapping fails
Date: Sun, 21 Jun 2020 17:07:37 +0800
Message-ID: <20200621090800.1AE521C00D@dpdk.org> (raw)

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 <yunjian.wang@foxmail.com>
 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 64cd84a68..c87373b90 100644
--- a/drivers/bus/pci/linux/pci_vfio.c
+++ b/drivers/bus/pci/linux/pci_vfio.c
@@ -789,7 +789,8 @@ pci_vfio_map_resource_primary(struct rte_pci_device *dev)
-	close(vfio_dev_fd);
+	rte_vfio_release_device(rte_pci_get_sysfs_path(),
+				pci_addr, vfio_dev_fd);
 	return -1;
@@ -857,7 +858,8 @@ pci_vfio_map_resource_secondary(struct rte_pci_device *dev)
 	return 0;
-	close(vfio_dev_fd);
+	rte_vfio_release_device(rte_pci_get_sysfs_path(),
+				pci_addr, vfio_dev_fd);
 	return -1;

             reply	other threads:[~2020-06-21  9:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-21  9:07 Yunjian Wang [this message]
2020-09-11 11:08 ` [dpdk-dev] [PATCH v2 RESEND] " wangyunjian
2020-09-17 10:35   ` Burakov, Anatoly
2020-10-05  8:12   ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200621090800.1AE521C00D@dpdk.org \
    --to=yunjian.wang@foxmail.com \
    --cc=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=stable@dpdk.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/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 dev dev/ https://inbox.dpdk.org/dev \
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:

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