From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEHUu-00064g-K3 for qemu-devel@nongnu.org; Thu, 03 May 2018 12:54:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEHUt-0001Zz-SD for qemu-devel@nongnu.org; Thu, 03 May 2018 12:54:24 -0400 Date: Thu, 3 May 2018 12:54:10 -0400 From: Jeff Cody Message-ID: <20180503165410.GA6216@localhost.localdomain> References: <20180503153509.22223-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180503153509.22223-1-kwolf@redhat.com> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH] sheepdog: Fix sd_co_create_opts() memory leaks List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: qemu-block@nongnu.org, qemu-devel@nongnu.org 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 > --- > 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