qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] block/rbd: fix memory leak


From: Amos Kong
Subject: Re: [Qemu-devel] [PATCH] block/rbd: fix memory leak
Date: Thu, 4 Dec 2014 14:51:44 +0800
User-agent: Mutt/1.5.23 (2014-03-12)

On Thu, Dec 04, 2014 at 02:34:11PM +0800, address@hidden wrote:
> From: Gonglei <address@hidden>
> 
> Variable local_err going out of scope
> leaks the storage it points to.
> 
> Cc: Markus Armbruster <address@hidden>
> Signed-off-by: Gonglei <address@hidden>
> ---
>  block/rbd.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/block/rbd.c b/block/rbd.c
> index 5b5a64a..f3ab2dd 100644
> --- a/block/rbd.c
> +++ b/block/rbd.c
> @@ -459,7 +459,7 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict 
> *options, int flags,
>      clientname = qemu_rbd_parse_clientname(conf, clientname_buf);
>      r = rados_create(&s->cluster, clientname);
>      if (r < 0) {
> -        error_setg(&local_err, "error initializing");
> +        error_setg(errp, "error initializing");
>          goto failed_opts;
>      }
>  
> @@ -495,19 +495,19 @@ static int qemu_rbd_open(BlockDriverState *bs, QDict 
> *options, int flags,
>  
>      r = rados_connect(s->cluster);
>      if (r < 0) {
> -        error_setg(&local_err, "error connecting");
> +        error_setg(errp, "error connecting");
>          goto failed_shutdown;
>      }
>  
>      r = rados_ioctx_create(s->cluster, pool, &s->io_ctx);
>      if (r < 0) {
> -        error_setg(&local_err, "error opening pool %s", pool);
> +        error_setg(errp, "error opening pool %s", pool);
>          goto failed_shutdown;
>      }
>  
>      r = rbd_open(s->io_ctx, s->name, &s->image, s->snap);
>      if (r < 0) {
> -        error_setg(&local_err, "error reading header from %s", s->name);
> +        error_setg(errp, "error reading header from %s", s->name);
>          goto failed_open;
>      }

'local_err' was defined for collecting error insider qemu_opts_absorb_qdict().
We should set error to 'errp', then the error can be passed to caller,
and free the memory in future.

Reviewed-by: Amos Kong <address@hidden>

-- 
                        Amos.

Attachment: signature.asc
Description: Digital signature


reply via email to

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