mirror: Fix resource leak when bdrv_getlength fails
authorFam Zheng <famz@redhat.com>
Tue, 29 Apr 2014 10:09:09 +0000 (18:09 +0800)
committerKevin Wolf <kwolf@redhat.com>
Tue, 29 Apr 2014 11:43:00 +0000 (13:43 +0200)
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

index 95366adb3a553e6da582d33daf4c1faf4f300622..403714c1ea356dcb3ad32618b356b148cf834b4d 100644 (file)
@@ -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);