Patchwork [PULL,06/31] mirror: Check for bdrv_get_info result

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

Comments

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

bdrv_get_info could fail. Add check before using the returned value.

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

Patch

diff --git a/block/mirror.c b/block/mirror.c
index 403714c..1c38aa8 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -339,7 +339,10 @@  static void coroutine_fn mirror_run(void *opaque)
     bdrv_get_backing_filename(s->target, backing_filename,
                               sizeof(backing_filename));
     if (backing_filename[0] && !s->target->backing_hd) {
-        bdrv_get_info(s->target, &bdi);
+        ret = bdrv_get_info(s->target, &bdi);
+        if (ret < 0) {
+            goto immediate_exit;
+        }
         if (s->granularity < bdi.cluster_size) {
             s->buf_size = MAX(s->buf_size, bdi.cluster_size);
             s->cow_bitmap = bitmap_new(length);