From bb23a7362a7942739f080990a53e44afc319e36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 5 Jul 2018 18:16:29 +0200 Subject: [PATCH 1/2] qga: fix 'driver' leak in guest-get-fsinfo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 'driver' is leaked when the loop is not broken. Leak introduced by commit 743c71d03c20d64f2bae5fba6f26cdf5e4b1bda6, spotted by ASAN. Signed-off-by: Marc-André Lureau Reviewed-by: Laszlo Ersek Signed-off-by: Michael Roth --- qga/commands-posix.c | 1 + 1 file changed, 1 insertion(+) diff --git a/qga/commands-posix.c b/qga/commands-posix.c index 233f78a406..c46767b0dd 100644 --- a/qga/commands-posix.c +++ b/qga/commands-posix.c @@ -890,6 +890,7 @@ static void build_guest_fsinfo_for_real_device(char const *syspath, break; } + g_free(driver); if (sscanf(p, "/%x:%x:%x.%x%n", pci, pci + 1, pci + 2, pci + 3, &pcilen) == 4) { p += pcilen; From d9c745c1768727aadd77e352c85114bc61e67bd4 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Sun, 15 Jul 2018 18:21:56 +0200 Subject: [PATCH 2/2] qga: fix file descriptor leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The file descriptor for /sys/power/state was never closed. Reported by Coverity. Signed-off-by: Paolo Bonzini Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Michael Roth --- 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; }