All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH for-2.5] block/qapi: Plug memory leak on query-block error path
Date: Fri, 20 Nov 2015 10:57:31 -0700	[thread overview]
Message-ID: <564F5F0B.1080305@redhat.com> (raw)
In-Reply-To: <1448024015-31081-1-git-send-email-armbru@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1297 bytes --]

On 11/20/2015 05:53 AM, Markus Armbruster wrote:
> Spotted by Coverity.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  block/qapi.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/block/qapi.c b/block/qapi.c
> index d20262d..267f147 100644
> --- a/block/qapi.c
> +++ b/block/qapi.c
> @@ -436,7 +436,9 @@ BlockInfoList *qmp_query_block(Error **errp)
>          bdrv_query_info(blk, &info->value, &local_err);
>          if (local_err) {
>              error_propagate(errp, local_err);
> -            goto err;
> +            g_free(info);
> +            qapi_free_BlockInfoList(head);
> +            return NULL;
>          }
>  

Only info was leaked, but inlining the entire 'err' label into its one
use was easier than hoisting the declaration of info out of the loop.

Reviewed-by: Eric Blake <eblake@redhat.com>

>          *p_next = info;
> @@ -444,10 +446,6 @@ BlockInfoList *qmp_query_block(Error **errp)
>      }
>  
>      return head;
> -
> - err:
> -    qapi_free_BlockInfoList(head);
> -    return NULL;
>  }
>  
>  BlockStatsList *qmp_query_blockstats(bool has_query_nodes,
> 

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2015-11-20 17:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-20 12:53 [Qemu-devel] [PATCH] block/qapi: Plug memory leak on query-block error path Markus Armbruster
2015-11-20 17:57 ` Eric Blake [this message]
2015-11-20 18:00 ` Eric Blake
2015-11-23 10:10 ` 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=564F5F0B.1080305@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.