Patchwork [1/2] qemu-ga: Plug memory leak in guest_fsfreeze_cleanup()

login
register
mail settings
Submitter Markus Armbruster
Date Jan. 16, 2013, 5:15 p.m.
Message ID <1358356509-28742-2-git-send-email-armbru@redhat.com>
Download mbox | patch
Permalink /patch/212840/
State New
Headers show

Comments

Markus Armbruster - Jan. 16, 2013, 5:15 p.m.
Neglects to free errors allocated by qmp_guest_fsfreeze_thaw().
Spotted by Coverity.

While there, drop the test whether return value is negative (it's
never true), and improve logging.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 qga/commands-posix.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Patch

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 77f6ee7..f95ebc8 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -611,13 +611,14 @@  int64_t qmp_guest_fsfreeze_thaw(Error **err)
 
 static void guest_fsfreeze_cleanup(void)
 {
-    int64_t ret;
     Error *err = NULL;
 
     if (ga_is_frozen(ga_state) == GUEST_FSFREEZE_STATUS_FROZEN) {
-        ret = qmp_guest_fsfreeze_thaw(&err);
-        if (ret < 0 || err) {
-            slog("failed to clean up frozen filesystems");
+        qmp_guest_fsfreeze_thaw(&err);
+        if (err) {
+            slog("failed to clean up frozen filesystems: %s",
+                 error_get_pretty(err));
+            error_free(err);
         }
     }
 }