[dpdk-dev] eal: fix resource leak

Message ID 1460368014-9012-1-git-send-email-danielx.t.mrzyglod@intel.com (mailing list archive)
State Accepted, archived
Headers

Commit Message

Daniel Mrzyglod April 11, 2016, 9:46 a.m. UTC
  CID 13289 (#1-2 of 2): Resource leak (RESOURCE_LEAK):
The system resource will not be reclaimed and reused, reducing the future availability of the resource.
In pci_vfio_get_group_fd: Leak of memory or pointers to system resources

Fixes: ff0b67d1c868 ("vfio: DMA mapping")

Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
---
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Anatoly Burakov April 11, 2016, 10:25 a.m. UTC | #1
> Subject: [PATCH] eal: fix resource leak
> 
> CID 13289 (#1-2 of 2): Resource leak (RESOURCE_LEAK):
> The system resource will not be reclaimed and reused, reducing the future
> availability of the resource.
> In pci_vfio_get_group_fd: Leak of memory or pointers to system resources
> 
> Fixes: ff0b67d1c868 ("vfio: DMA mapping")
> 
> Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
> ---
>  lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> index fdfdeb4..10266f8 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
> @@ -535,6 +535,7 @@ pci_vfio_get_group_fd(int iommu_group_no)
>  		/* if the fd is valid, create a new group for it */
>  		if (vfio_cfg.vfio_group_idx == VFIO_MAX_GROUPS) {
>  			RTE_LOG(ERR, EAL, "Maximum number of VFIO
> groups reached!\n");
> +			close(vfio_group_fd);
>  			return -1;
>  		}
>  		vfio_cfg.vfio_groups[vfio_cfg.vfio_group_idx].group_no =
> iommu_group_no;
> --
> 2.5.5

Acked-by: Anatoly  Burakov <anatoly.burakov@intel.com>
  
Thomas Monjalon April 11, 2016, 12:36 p.m. UTC | #2
> > CID 13289 (#1-2 of 2): Resource leak (RESOURCE_LEAK):
> > The system resource will not be reclaimed and reused, reducing the future
> > availability of the resource.
> > In pci_vfio_get_group_fd: Leak of memory or pointers to system resources
> > 
> > Fixes: ff0b67d1c868 ("vfio: DMA mapping")
> > 
> > Signed-off-by: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
> 
> Acked-by: Anatoly  Burakov <anatoly.burakov@intel.com>

Applied, thanks
  

Patch

diff --git a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
index fdfdeb4..10266f8 100644
--- a/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ b/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -535,6 +535,7 @@  pci_vfio_get_group_fd(int iommu_group_no)
 		/* if the fd is valid, create a new group for it */
 		if (vfio_cfg.vfio_group_idx == VFIO_MAX_GROUPS) {
 			RTE_LOG(ERR, EAL, "Maximum number of VFIO groups reached!\n");
+			close(vfio_group_fd);
 			return -1;
 		}
 		vfio_cfg.vfio_groups[vfio_cfg.vfio_group_idx].group_no = iommu_group_no;