Patchwork [PULL,05/31] mirror: Fix resource leak when bdrv_getlength fails

login
register
mail settings
Submitter Kevin Wolf
Date April 30, 2014, 6:23 p.m.
Message ID <1398882243-14783-6-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/344282/
State New
Headers show

Comments

Kevin Wolf - April 30, 2014, 6:23 p.m.
From: Fam Zheng <famz@redhat.com>

The direct return will skip releasing of all the resouces at
immediate_exit, don't miss that.

Signed-off-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/mirror.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch

diff --git a/block/mirror.c b/block/mirror.c
index 95366ad..403714c 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -325,8 +325,8 @@  static void coroutine_fn mirror_run(void *opaque)
 
     s->common.len = bdrv_getlength(bs);
     if (s->common.len <= 0) {
-        block_job_completed(&s->common, s->common.len);
-        return;
+        ret = s->common.len;
+        goto immediate_exit;
     }
 
     length = DIV_ROUND_UP(s->common.len, s->granularity);