diff options
author | Kevin Wolf <kwolf@redhat.com> | 2018-05-03 17:35:09 +0200 |
---|---|---|
committer | Jeff Cody <jcody@redhat.com> | 2018-05-08 10:47:27 -0400 |
commit | a2cb9239b7610ffb00f9ced5cd7640d40b0e1ccf (patch) | |
tree | 20271b0c00f68b5db720b38823505e4a0bb57add /block/sheepdog.c | |
parent | dc885fff972c447f51572afc4c921a26b880731b (diff) | |
download | qemu-a2cb9239b7610ffb00f9ced5cd7640d40b0e1ccf.zip qemu-a2cb9239b7610ffb00f9ced5cd7640d40b0e1ccf.tar.gz qemu-a2cb9239b7610ffb00f9ced5cd7640d40b0e1ccf.tar.bz2 |
sheepdog: Fix sd_co_create_opts() memory leaks
Both the option string for the 'redundancy' option and the
SheepdogRedundancy object that is created accordingly could be leaked in
error paths. This fixes the memory leaks.
Reported by Coverity (CID 1390614 and 1390641).
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-id: 20180503153509.22223-1-kwolf@redhat.com
Reviewed-by: Jeff Cody <jcody@redhat.com>
Signed-off-by: Jeff Cody <jcody@redhat.com>
Diffstat (limited to 'block/sheepdog.c')
-rw-r--r-- | block/sheepdog.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/block/sheepdog.c b/block/sheepdog.c index 07529f4..fed2a04 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -1987,6 +1987,7 @@ static SheepdogRedundancy *parse_redundancy_str(const char *opt) } else { ret = qemu_strtol(n2, NULL, 10, &parity); if (ret < 0) { + g_free(redundancy); return NULL; } @@ -2183,7 +2184,7 @@ static int coroutine_fn sd_co_create_opts(const char *filename, QemuOpts *opts, QDict *qdict, *location_qdict; QObject *crumpled; Visitor *v; - const char *redundancy; + char *redundancy; Error *local_err = NULL; int ret; @@ -2253,6 +2254,7 @@ static int coroutine_fn sd_co_create_opts(const char *filename, QemuOpts *opts, fail: qapi_free_BlockdevCreateOptions(create_options); qobject_unref(qdict); + g_free(redundancy); return ret; } |