[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 4/4] sheepdog: Fix sd_co_create_opts() memory leaks
From: |
Jeff Cody |
Subject: |
[Qemu-block] [PULL 4/4] sheepdog: Fix sd_co_create_opts() memory leaks |
Date: |
Tue, 8 May 2018 11:19:24 -0400 |
From: Kevin Wolf <address@hidden>
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 <address@hidden>
Message-id: address@hidden
Reviewed-by: Jeff Cody <address@hidden>
Signed-off-by: Jeff Cody <address@hidden>
---
block/sheepdog.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index 07529f4b1b..fed2a04797 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;
}
--
2.13.6
- [Qemu-block] [PULL 0/4] Block patches, Jeff Cody, 2018/05/08
- [Qemu-block] [PULL 0/4] Block patches, Jeff Cody, 2018/05/16
- [Qemu-block] [PULL 1/4] qemu-iotests: reduce chance of races in 185, Jeff Cody, 2018/05/16
- [Qemu-block] [PULL 2/4] blockjob: do not cancel timer in resume, Jeff Cody, 2018/05/16
- [Qemu-block] [PULL 3/4] nfs: Fix error path in nfs_options_qdict_to_qapi(), Jeff Cody, 2018/05/16
- [Qemu-block] [PULL 4/4] nfs: Remove processed options from QDict, Jeff Cody, 2018/05/16
- Re: [Qemu-block] [PULL 0/4] Block patches, Peter Maydell, 2018/05/17