From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48509) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXAt9-0004u6-1h for qemu-devel@nongnu.org; Fri, 18 Oct 2013 10:18:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VXAt4-0001tl-53 for qemu-devel@nongnu.org; Fri, 18 Oct 2013 10:18:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17983) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VXAt3-0001tf-Sz for qemu-devel@nongnu.org; Fri, 18 Oct 2013 10:18:46 -0400 From: Stefan Hajnoczi Date: Fri, 18 Oct 2013 16:18:30 +0200 Message-Id: <1382105915-27735-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1382105915-27735-1-git-send-email-stefanha@redhat.com> References: <1382105915-27735-1-git-send-email-stefanha@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 2/7] sd: Avoid access to NULL BlockDriverState List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Anthony Liguori From: Andreas F=C3=A4rber 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=C3=A4rber Signed-off-by: Stefan Hajnoczi --- hw/sd/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/sd/sd.c b/hw/sd/sd.c index 7380f06..4502ad1 100644 --- a/hw/sd/sd.c +++ b/hw/sd/sd.c @@ -494,7 +494,7 @@ SDState *sd_init(BlockDriverState *bs, bool is_spi) { SDState *sd; =20 - 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; } --=20 1.8.3.1