diff options
author | Fam Zheng <famz@redhat.com> | 2014-04-16 09:34:30 +0800 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-04-22 11:57:02 +0200 |
commit | b8afb520e479e693c227aa39c2fb7670743e104f (patch) | |
tree | 839fbe93b1b9398a61db63acd89b1e68dbe816de /block/mirror.c | |
parent | 4ab9dab5b9be0381e714d3fbe518689a72459011 (diff) |
block: Handle error of bdrv_getlength in bdrv_create_dirty_bitmap
bdrv_getlength could fail, check the return value before using it.
Return NULL and set errno if it fails. Callers are updated to handle
the error case.
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/mirror.c')
-rw-r--r-- | block/mirror.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/block/mirror.c b/block/mirror.c index 0ef41f999e..2618c3763c 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -605,7 +605,10 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target, s->granularity = granularity; s->buf_size = MAX(buf_size, granularity); - s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity); + s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, errp); + if (!s->dirty_bitmap) { + return; + } bdrv_set_enable_write_cache(s->target, true); bdrv_set_on_error(s->target, on_target_error, on_target_error); bdrv_iostatus_enable(s->target); |