From: Peter Lieven Date: Tue, 24 Sep 2013 13:35:09 +0000 (+0200) Subject: block/get_block_status: avoid segfault if there is no backing_hd X-Git-Tag: v1.7.0-rc0~84^2~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1f9db2243c1b987c834fe559a8e73b3178f50c2b;p=thirdparty%2Fqemu.git block/get_block_status: avoid segfault if there is no backing_hd Reviewed-by: Eric Blake Signed-off-by: Peter Lieven Signed-off-by: Kevin Wolf --- diff --git a/block.c b/block.c index 9b444b34436..3366017aeac 100644 --- a/block.c +++ b/block.c @@ -3169,7 +3169,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, if (!(ret & BDRV_BLOCK_DATA)) { if (bdrv_has_zero_init(bs)) { ret |= BDRV_BLOCK_ZERO; - } else { + } else if (bs->backing_hd) { BlockDriverState *bs2 = bs->backing_hd; int64_t length2 = bdrv_getlength(bs2); if (length2 >= 0 && sector_num >= (length2 >> BDRV_SECTOR_BITS)) {