All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qemu-img: eliminate memory leak
@ 2016-02-25 22:53 Paolo Bonzini
  2016-02-26  7:31 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
  2016-02-26  9:23 ` [Qemu-devel] " Kevin Wolf
  0 siblings, 2 replies; 3+ messages in thread
From: Paolo Bonzini @ 2016-02-25 22:53 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, qemu-block

Not particularly important since qemu-img exits immediately after
calling img_rebase, but easily fixed.  Coverity says thanks.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qemu-img.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index 2edb139..3103150 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2775,6 +2775,8 @@ static int img_snapshot(int argc, char **argv)
 static int img_rebase(int argc, char **argv)
 {
     BlockBackend *blk = NULL, *blk_old_backing = NULL, *blk_new_backing = NULL;
+    uint8_t *buf_old = NULL;
+    uint8_t *buf_new = NULL;
     BlockDriverState *bs = NULL;
     char *filename;
     const char *fmt, *cache, *src_cache, *out_basefmt, *out_baseimg;
@@ -2957,8 +2959,6 @@ static int img_rebase(int argc, char **argv)
         int64_t new_backing_num_sectors = 0;
         uint64_t sector;
         int n;
-        uint8_t * buf_old;
-        uint8_t * buf_new;
         float local_progress = 0;
 
         buf_old = blk_blockalign(blk, IO_BUF_SIZE);
@@ -3070,9 +3070,6 @@ static int img_rebase(int argc, char **argv)
             }
             qemu_progress_print(local_progress, 100);
         }
-
-        qemu_vfree(buf_old);
-        qemu_vfree(buf_new);
     }
 
     /*
@@ -3108,6 +3105,8 @@ out:
         blk_unref(blk_old_backing);
         blk_unref(blk_new_backing);
     }
+    qemu_vfree(buf_old);
+    qemu_vfree(buf_new);
 
     blk_unref(blk);
     if (ret) {
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [Qemu-block] [PATCH] qemu-img: eliminate memory leak
  2016-02-25 22:53 [Qemu-devel] [PATCH] qemu-img: eliminate memory leak Paolo Bonzini
@ 2016-02-26  7:31 ` Alberto Garcia
  2016-02-26  9:23 ` [Qemu-devel] " Kevin Wolf
  1 sibling, 0 replies; 3+ messages in thread
From: Alberto Garcia @ 2016-02-26  7:31 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: kwolf, qemu-block

On Thu 25 Feb 2016 11:53:54 PM CET, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Not particularly important since qemu-img exits immediately after
> calling img_rebase, but easily fixed.  Coverity says thanks.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Alberto Garcia <berto@igalia.com>

Berto

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] qemu-img: eliminate memory leak
  2016-02-25 22:53 [Qemu-devel] [PATCH] qemu-img: eliminate memory leak Paolo Bonzini
  2016-02-26  7:31 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
@ 2016-02-26  9:23 ` Kevin Wolf
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2016-02-26  9:23 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: qemu-devel, qemu-block

Am 25.02.2016 um 23:53 hat Paolo Bonzini geschrieben:
> Not particularly important since qemu-img exits immediately after
> calling img_rebase, but easily fixed.  Coverity says thanks.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Thanks, applied to the block branch.

Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-26  9:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-25 22:53 [Qemu-devel] [PATCH] qemu-img: eliminate memory leak Paolo Bonzini
2016-02-26  7:31 ` [Qemu-devel] [Qemu-block] " Alberto Garcia
2016-02-26  9:23 ` [Qemu-devel] " Kevin Wolf

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.