Description: backport of dpdk 16.04-rc fix for LP: #1568838

Forwarded: n/a (already upstream)
Author: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Last-Update: 2016-04-11

From fe671356ed0d9b349bd257b8fcb30adf7da103e1 Mon Sep 17 00:00:00 2001
From: Daniel Mrzyglod <danielx.t.mrzyglod@intel.com>
Date: Mon, 11 Apr 2016 11:46:54 +0200
Subject: [PATCH] vfio: fix resource leak

Coverity ID 13289: 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>
---
 lib/librte_eal/linuxapp/eal/eal_pci_vfio.c | 1 +
 1 file changed, 1 insertion(+)

Index: dpdk/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
===================================================================
--- dpdk.orig/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
+++ dpdk/lib/librte_eal/linuxapp/eal/eal_pci_vfio.c
@@ -448,6 +448,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;
