From: "Daniel P. Berrange" <berrange(a)redhat.com>
In libvirt-sandbox-init-qemu if open() returned -1 and errno
was set to EEXIST then close() would be called on a FD that
was -1. This fixes a coverity identified issue.
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
libvirt-sandbox/libvirt-sandbox-init-qemu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libvirt-sandbox/libvirt-sandbox-init-qemu.c
b/libvirt-sandbox/libvirt-sandbox-init-qemu.c
index 012c6a2..44f5de0 100644
--- a/libvirt-sandbox/libvirt-sandbox-init-qemu.c
+++ b/libvirt-sandbox/libvirt-sandbox-init-qemu.c
@@ -123,7 +123,8 @@ mount_mkfile(const char *file, int mode)
__func__, file, strerror(errno));
exit_poweroff();
}
- close(fd);
+ if (fd != -1)
+ close(fd);
}
static void
--
1.8.3.1