Blob Blame Raw
From 25e634bffca2048bc0df66ff00a9c46f00d1c3c2 Mon Sep 17 00:00:00 2001
From: Alex Williamson <alex.williamson@redhat.com>
Date: Mon, 3 Dec 2018 22:02:16 +0000
Subject: [PATCH 15/16] vfio/pci: Fix failure to close file descriptor on error

RH-Author: Alex Williamson <alex.williamson@redhat.com>
Message-id: <154387453688.27651.6584558037969560928.stgit@gimli.home>
Patchwork-id: 83240
O-Subject: [RHEL-8.0 qemu-kvm PATCH 6/7] vfio/pci: Fix failure to close file descriptor on error
Bugzilla: 1650272
RH-Acked-by: Peter Xu <peterx@redhat.com>
RH-Acked-by: Auger Eric <eric.auger@redhat.com>
RH-Acked-by: Cornelia Huck <cohuck@redhat.com>
RH-Acked-by: David Hildenbrand <david@redhat.com>

Bugzilla: 1650272

A new error path fails to close the device file descriptor when
triggered by a ballooning incompatibility within the group.  Fix it.

Fixes: 238e91728503 ("vfio/ccw/pci: Allow devices to opt-in for ballooning")
Reviewed-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
(cherry picked from commit 8709b3954d4161bad30ccc435408ec50e10f53cc)
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
---
 hw/vfio/common.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index cda2d1f..3ab92bd 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1424,6 +1424,7 @@ int vfio_get_device(VFIOGroup *group, const char *name,
         if (!QLIST_EMPTY(&group->device_list)) {
             error_setg(errp,
                        "Inconsistent device balloon setting within group");
+            close(fd);
             return -1;
         }
 
-- 
1.8.3.1