Blob Blame Raw
From cb57c159b8ffe151ce61750507c635d1d05e51b5 Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <pbonzini@redhat.com>
Date: Fri, 18 Oct 2013 08:14:50 +0200
Subject: [PATCH 25/81] block/get_block_status: avoid segfault if there is no backing_hd

RH-Author: Paolo Bonzini <pbonzini@redhat.com>
Message-id: <1382084091-16636-26-git-send-email-pbonzini@redhat.com>
Patchwork-id: 55008
O-Subject: [RHEL 7.0 qemu-kvm PATCH 25/26] block/get_block_status: avoid segfault if there is no backing_hd
Bugzilla: 989646
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>

From: Peter Lieven <pl@kamp.de>

Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit 1f9db2243c1b987c834fe559a8e73b3178f50c2b)
---
 block.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
---
 block.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/block.c b/block.c
index 02e111e..5c49461 100644
--- a/block.c
+++ b/block.c
@@ -3076,7 +3076,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)) {
-- 
1.7.1