218e99
From 6c6316c53a1e2ddd34c31ecf5d757646482c4202 Mon Sep 17 00:00:00 2001
218e99
From: Kevin Wolf <kwolf@redhat.com>
218e99
Date: Tue, 5 Nov 2013 14:09:15 +0100
218e99
Subject: [PATCH 62/87] sd: Avoid access to NULL BlockDriverState
218e99
MIME-Version: 1.0
218e99
Content-Type: text/plain; charset=UTF-8
218e99
Content-Transfer-Encoding: 8bit
218e99
218e99
RH-Author: Kevin Wolf <kwolf@redhat.com>
218e99
Message-id: <1383660558-32096-22-git-send-email-kwolf@redhat.com>
218e99
Patchwork-id: 55400
218e99
O-Subject: [RHEL-7.0 qemu-kvm PATCH 21/24] sd: Avoid access to NULL BlockDriverState
218e99
Bugzilla: 978402
218e99
RH-Acked-by: Fam Zheng <famz@redhat.com>
218e99
RH-Acked-by: Max Reitz <mreitz@redhat.com>
218e99
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
218e99
218e99
From: Andreas Färber <afaerber@suse.de>
218e99
218e99
Commit 4f8a066b5fc254eeaabbbde56ba4f5b29cc68fdf (blockdev: Remove IF_*
218e99
check for read-only blockdev_init) added a usage of bdrv_is_read_only()
218e99
to sd_init(), which is called for versatilepb, versatileab and
218e99
xilinx-zynq-a9 machines among others with NULL argument by default,
218e99
causing the new qom-test to fail.
218e99
218e99
Add a check to prevent this.
218e99
218e99
Suggested-by: Kevin Wolf <kwolf@redhat.com>
218e99
Signed-off-by: Andreas Färber <afaerber@suse.de>
218e99
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
218e99
(cherry picked from commit 794cbc26eb94ce13c75d105eea9ff0afff56e2c2)
218e99
218e99
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
218e99
---
218e99
 hw/sd/sd.c | 2 +-
218e99
 1 file changed, 1 insertion(+), 1 deletion(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 hw/sd/sd.c |    2 +-
218e99
 1 files changed, 1 insertions(+), 1 deletions(-)
218e99
218e99
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
218e99
index e816c78..c9651b9 100644
218e99
--- a/hw/sd/sd.c
218e99
+++ b/hw/sd/sd.c
218e99
@@ -492,7 +492,7 @@ SDState *sd_init(BlockDriverState *bs, bool is_spi)
218e99
 {
218e99
     SDState *sd;
218e99
 
218e99
-    if (bdrv_is_read_only(bs)) {
218e99
+    if (bs && bdrv_is_read_only(bs)) {
218e99
         fprintf(stderr, "sd_init: Cannot use read-only drive\n");
218e99
         return NULL;
218e99
     }
218e99
-- 
218e99
1.7.1
218e99