[Qemu-devel] [PULL for-3.0 2/2] qga: fix file descriptor leak

Michael Roth posted 2 patches 7 years, 3 months ago
There is a newer version of this series
[Qemu-devel] [PULL for-3.0 2/2] qga: fix file descriptor leak
Posted by Michael Roth 7 years, 3 months ago
From: Paolo Bonzini <pbonzini@redhat.com>

The file descriptor for /sys/power/state was never closed.  Reported
by Coverity.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 qga/commands-posix.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index c46767b0dd..37e8a2d791 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -1652,6 +1652,7 @@ static bool linux_sys_state_supports_mode(SuspendMode mode, Error **errp)
     }
 
     ret = read(fd, buf, sizeof(buf) - 1);
+    close(fd);
     if (ret <= 0) {
         return false;
     }
-- 
2.11.0