qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
Cc: Max Reitz <mreitz@redhat.com>,
	qemu-devel@nongnu.org, Paolo Bonzini <pbonzini@redhat.com>,
	qemu-block@nongnu.org, Markus Armbruster <armbru@redhat.com>,
	Eric Blake <eblake@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] block/crypto: Simplify block_crypto_co_create_opts_luks to avoid a memory leak
Date: Thu, 5 Jul 2018 12:20:22 +0200	[thread overview]
Message-ID: <20180705102022.GE3309@localhost.localdomain> (raw)
In-Reply-To: <20180704150229.9948-1-f4bug@amsat.org>

Am 04.07.2018 um 17:02 hat Philippe Mathieu-Daudé geschrieben:
> After 1ec4f4160a1 Coverity reported:
> 
>   Variable cryptoopts going out of scope leaks the storage it points to.
> 
> Fixes: Coverity CID 1393782 (Resource leak)
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

I already sent a much simpler fix:
[PATCH] block/crypto: Fix memory leak in create error path

The only thing that is needed is replacing the return with a goto.
Splitting it in three different error paths is unnecessary because the
cleanup function handle NULL values just fine.

> I think this check is superfluous but I respected the previous code:
> 
>      ret = block_crypto_co_create_generic(bs, size, create_opts, errp);
>      if (ret > 0) {
>          ret = 0;
>      }

It is wrong, too. The old code keep the error code, goto fail skipped
the ret = 0.

Kevin

  reply	other threads:[~2018-07-05 10:20 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-04 15:02 [Qemu-devel] [PATCH] block/crypto: Simplify block_crypto_co_create_opts_luks to avoid a memory leak Philippe Mathieu-Daudé
2018-07-05 10:20 ` Kevin Wolf [this message]
2018-07-05 16:04   ` Philippe Mathieu-Daudé
2018-07-05 16:21     ` Kevin Wolf

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=20180705102022.GE3309@localhost.localdomain \
    --to=kwolf@redhat.com \
    --cc=armbru@redhat.com \
    --cc=eblake@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@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).