diff options
author | Markus Armbruster <armbru@redhat.com> | 2017-03-06 20:00:46 +0100 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2017-03-07 14:53:29 +0100 |
commit | 85a82e852d01c2cd26d3126c5900a5bd1c464609 (patch) | |
tree | d9c829ce29d9c0b774350b412f849a830b26ed52 /block | |
parent | e152ef7a98c584e8d5de88d7a5294ab6a8e7059f (diff) | |
download | qemu-85a82e852d01c2cd26d3126c5900a5bd1c464609.zip qemu-85a82e852d01c2cd26d3126c5900a5bd1c464609.tar.gz qemu-85a82e852d01c2cd26d3126c5900a5bd1c464609.tar.bz2 |
gluster: Plug memory leaks in qemu_gluster_parse_json()
To reproduce, run
$ valgrind qemu-system-x86_64 --nodefaults -S --drive driver=gluster,volume=testvol,path=/a/b/c,server.0.type=xxx
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r-- | block/gluster.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/block/gluster.c b/block/gluster.c index 6fbcf9e..991f18f 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -480,7 +480,7 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, QDict *options, Error **errp) { QemuOpts *opts; - GlusterServer *gsconf; + GlusterServer *gsconf = NULL; GlusterServerList *curr = NULL; QDict *backing_options = NULL; Error *local_err = NULL; @@ -529,17 +529,16 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, } ptr = qemu_opt_get(opts, GLUSTER_OPT_TYPE); - gsconf = g_new0(GlusterServer, 1); - gsconf->type = qapi_enum_parse(GlusterTransport_lookup, ptr, - GLUSTER_TRANSPORT__MAX, - GLUSTER_TRANSPORT__MAX, - &local_err); if (!ptr) { error_setg(&local_err, QERR_MISSING_PARAMETER, GLUSTER_OPT_TYPE); error_append_hint(&local_err, GERR_INDEX_HINT, i); goto out; } + gsconf = g_new0(GlusterServer, 1); + gsconf->type = qapi_enum_parse(GlusterTransport_lookup, ptr, + GLUSTER_TRANSPORT__MAX, -1, + &local_err); if (local_err) { error_append_hint(&local_err, "Parameter '%s' may be 'tcp' or 'unix'\n", @@ -626,8 +625,10 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, curr->next->value = gsconf; curr = curr->next; } + gsconf = NULL; - qdict_del(backing_options, str); + QDECREF(backing_options); + backing_options = NULL; g_free(str); str = NULL; } @@ -636,11 +637,10 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, out: error_propagate(errp, local_err); + qapi_free_GlusterServer(gsconf); qemu_opts_del(opts); - if (str) { - qdict_del(backing_options, str); - g_free(str); - } + g_free(str); + QDECREF(backing_options); errno = EINVAL; return -errno; } |