* [Qemu-devel] [PATCH] sheepdog: Fix sd_co_create_opts() memory leaks
@ 2018-05-03 15:35 Kevin Wolf
2018-05-03 16:54 ` [Qemu-devel] [Qemu-block] " Jeff Cody
0 siblings, 1 reply; 2+ messages in thread
From: Kevin Wolf @ 2018-05-03 15:35 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, qemu-devel
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>
---
block/sheepdog.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/block/sheepdog.c b/block/sheepdog.c
index a2f26efc0e..6ec647e558 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);
QDECREF(qdict);
+ g_free(redundancy);
return ret;
}
--
2.13.6
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] [Qemu-block] [PATCH] sheepdog: Fix sd_co_create_opts() memory leaks
2018-05-03 15:35 [Qemu-devel] [PATCH] sheepdog: Fix sd_co_create_opts() memory leaks Kevin Wolf
@ 2018-05-03 16:54 ` Jeff Cody
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Cody @ 2018-05-03 16:54 UTC (permalink / raw)
To: Kevin Wolf; +Cc: qemu-block, qemu-devel
On Thu, May 03, 2018 at 05:35:09PM +0200, Kevin Wolf wrote:
> 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>
> ---
> block/sheepdog.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/block/sheepdog.c b/block/sheepdog.c
> index a2f26efc0e..6ec647e558 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);
> QDECREF(qdict);
> + g_free(redundancy);
> return ret;
> }
>
> --
> 2.13.6
>
>
Thanks,
Reviewed & applied to my block branch:
git://github.com/codyprime/qemu-kvm-jtc block
-Jeff
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-03 16:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-03 15:35 [Qemu-devel] [PATCH] sheepdog: Fix sd_co_create_opts() memory leaks Kevin Wolf
2018-05-03 16:54 ` [Qemu-devel] [Qemu-block] " Jeff Cody
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).