diff mbox

block: Fix memory leak in hmp_drive_add_node()

Message ID 1458123417-7735-1-git-send-email-kwolf@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Kevin Wolf March 16, 2016, 10:16 a.m. UTC
hmp_drive_add_node() leaked qdict in the error path when no node-name is
specified.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 blockdev.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Markus Armbruster March 16, 2016, 12:26 p.m. UTC | #1
Kevin Wolf <kwolf@redhat.com> writes:

> hmp_drive_add_node() leaked qdict in the error path when no node-name is
> specified.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  blockdev.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/blockdev.c b/blockdev.c
> index e7b8676..50410bf 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -3898,6 +3898,7 @@ void hmp_drive_add_node(Monitor *mon, const char *optstr)
>      qdict = qemu_opts_to_qdict(opts, NULL);
>  
>      if (!qdict_get_try_str(qdict, "node-name")) {
> +        QDECREF(qdict);
>          error_report("'node-name' needs to be specified");
>          goto out;
>      }

Reviewed-by: Markus Armbruster <armbru@redhat.com>
diff mbox

Patch

diff --git a/blockdev.c b/blockdev.c
index e7b8676..50410bf 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3898,6 +3898,7 @@  void hmp_drive_add_node(Monitor *mon, const char *optstr)
     qdict = qemu_opts_to_qdict(opts, NULL);
 
     if (!qdict_get_try_str(qdict, "node-name")) {
+        QDECREF(qdict);
         error_report("'node-name' needs to be specified");
         goto out;
     }