Skip to contentSkip to conversation

qga: fix file descriptor leak

PATCH Applied Paolo Bonzini 3 participants 3 messages Jul 15, 2018 – Jul 16, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qga: fix file descriptor leak

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

---
 qga/commands-posix.c | 1 +
 1 file changed, 1 insertion(+)
qga/commands-posix.c +1 -0
index 233f78a406..4160aceaed 100644
@@ -1651,6 +1651,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;
     }
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Paolo Bonzini

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

Quoted 17 lines
---
 qga/commands-posix.c | 1 +
 1 file changed, 1 insertion(+)
qga/commands-posix.c +1 -0
index 233f78a406..4160aceaed 100644
@@ -1651,6 +1651,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;
     }
Applied
#2 lore raw
In reply to Paolo Bonzini

Quoting Paolo Bonzini (2018-07-15 11:21:56)

Quoted 4 lines

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

Thanks, applied to qga tree:
https://github.com/mdroth/qemu/commits/qga

Quoted 19 lines
---
 qga/commands-posix.c | 1 +
 1 file changed, 1 insertion(+)
qga/commands-posix.c +1 -0
index 233f78a406..4160aceaed 100644
@@ -1651,6 +1651,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;
     }
Signature · 1 line
2.17.1