[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v2 12/15] gluster: Plug memory leaks in qemu_gluster
From: |
Markus Armbruster |
Subject: |
[Qemu-block] [PATCH v2 12/15] gluster: Plug memory leaks in qemu_gluster_parse_json() |
Date: |
Mon, 6 Mar 2017 20:00:46 +0100 |
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 <address@hidden>
Reviewed-by: Niels de Vos <address@hidden>
---
block/gluster.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 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);
+ 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,
- GLUSTER_TRANSPORT__MAX,
+ GLUSTER_TRANSPORT__MAX, -1,
&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;
-
- }
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;
}
--
2.7.4
- [Qemu-block] [PATCH v2 04/15] sheepdog: Mark sd_snapshot_delete() lossage FIXME, (continued)
- [Qemu-block] [PATCH v2 04/15] sheepdog: Mark sd_snapshot_delete() lossage FIXME, Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 02/15] sheepdog: Fix error handling in sd_snapshot_delete(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 03/15] sheepdog: Fix error handling sd_create(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 01/15] sheepdog: Defuse time bomb in sd_open() error handling, Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 08/15] sheepdog: Use SocketAddress and socket_connect(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 10/15] gluster: Drop assumptions on SocketTransport names, Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 06/15] sheepdog: Don't truncate long VDI name in _open(), _create(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 05/15] sheepdog: Fix snapshot ID parsing in _open(), _create, _goto(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 12/15] gluster: Plug memory leaks in qemu_gluster_parse_json(),
Markus Armbruster <=
- [Qemu-block] [PATCH v2 07/15] sheepdog: Report errors in pseudo-filename more usefully, Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 13/15] qapi-schema: Rename GlusterServer to SocketAddressFlat, Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 09/15] sheepdog: Implement bdrv_parse_filename(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 11/15] gluster: Don't duplicate qapi-util.c's qapi_enum_parse(), Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 15/15] sheepdog: Support blockdev-add, Markus Armbruster, 2017/03/06
- [Qemu-block] [PATCH v2 14/15] qapi-schema: Rename SocketAddressFlat's variant tcp to inet, Markus Armbruster, 2017/03/06
- Re: [Qemu-block] [PATCH v2 00/15] block: A bunch of fixes for Sheepdog and Gluster, Kevin Wolf, 2017/03/07