qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [Qemu-devel] [PATCH for-2.5] block/qapi: Plug memory le


From: Eric Blake
Subject: Re: [Qemu-block] [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
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 11/20/2015 05:53 AM, Markus Armbruster wrote:
> Spotted by Coverity.
> 
> Signed-off-by: Markus Armbruster <address@hidden>
> ---
>  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 <address@hidden>

>          *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: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]