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