From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] sheepdog: Fix sd_co_create_opts() memory leaks
Date: Thu, 3 May 2018 17:35:09 +0200 [thread overview]
Message-ID: <20180503153509.22223-1-kwolf@redhat.com> (raw)
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
next reply other threads:[~2018-05-03 15:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-03 15:35 Kevin Wolf [this message]
2018-05-03 16:54 ` [Qemu-devel] [Qemu-block] [PATCH] sheepdog: Fix sd_co_create_opts() memory leaks Jeff Cody
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180503153509.22223-1-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).