qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PULL 5/6] block/qapi: Plug memory leak on query-block error path
Date: Wed, 25 Nov 2015 15:10:23 +0100	[thread overview]
Message-ID: <1448460624-16664-6-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1448460624-16664-1-git-send-email-kwolf@redhat.com>

From: Markus Armbruster <armbru@redhat.com>

Spotted by Coverity.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/qapi.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/block/qapi.c b/block/qapi.c
index d20262d..267f147 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -436,7 +436,9 @@ BlockInfoList *qmp_query_block(Error **errp)
         bdrv_query_info(blk, &info->value, &local_err);
         if (local_err) {
             error_propagate(errp, local_err);
-            goto err;
+            g_free(info);
+            qapi_free_BlockInfoList(head);
+            return NULL;
         }
 
         *p_next = info;
@@ -444,10 +446,6 @@ BlockInfoList *qmp_query_block(Error **errp)
     }
 
     return head;
-
- err:
-    qapi_free_BlockInfoList(head);
-    return NULL;
 }
 
 BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
-- 
1.8.3.1

  parent reply	other threads:[~2015-11-25 14:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-25 14:10 [Qemu-devel] [PULL 0/6] Block patches for 2.5.0-rc2 Kevin Wolf
2015-11-25 14:10 ` [Qemu-devel] [PULL 1/6] tests/Makefile: Add more dependencies for test-timed-average Kevin Wolf
2015-11-25 14:10 ` [Qemu-devel] [PULL 2/6] test-aio: Fix event notifier cleanup Kevin Wolf
2015-11-25 14:10 ` [Qemu-devel] [PULL 3/6] nand: fix flash erase when oob is in memory Kevin Wolf
2015-11-25 14:10 ` [Qemu-devel] [PULL 4/6] raw-posix.c: Make GetBSDPath() handle caching options Kevin Wolf
2015-11-25 14:10 ` Kevin Wolf [this message]
2015-11-25 14:10 ` [Qemu-devel] [PULL 6/6] qemu-iotests: Add -nographic when starting QEMU in 119 and 120 Kevin Wolf
2015-11-25 16:20 ` [Qemu-devel] [PULL 0/6] Block patches for 2.5.0-rc2 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1448460624-16664-6-git-send-email-kwolf@redhat.com \
    --to=kwolf@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).