hw/sd.c: fix sd_set_cb() crash when bdrv == NULL
authorAurelien Jarno <aurelien@aurel32.net>
Sun, 6 Mar 2011 19:02:40 +0000 (20:02 +0100)
committerAurelien Jarno <aurelien@aurel32.net>
Sun, 6 Mar 2011 19:02:40 +0000 (20:02 +0100)
sd_set_cb() calls bdrv_is_read_only() and bdrv_is_inserted() even if
no block driver is associated with the card reader.

This patch fixes the issues by not setting the irq in this case, this
fixes ARM versatile crash.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
hw/sd.c

diff --git a/hw/sd.c b/hw/sd.c
index 5e29752d9087cbfb1ea5ee1c511828ea58a73da8..f44a97092bd09e9af245e0ed7910a742e592d48f 100644 (file)
--- a/hw/sd.c
+++ b/hw/sd.c
@@ -460,8 +460,8 @@ void sd_set_cb(SDState *sd, qemu_irq readonly, qemu_irq insert)
 {
     sd->readonly_cb = readonly;
     sd->inserted_cb = insert;
-    qemu_set_irq(readonly, bdrv_is_read_only(sd->bdrv));
-    qemu_set_irq(insert, bdrv_is_inserted(sd->bdrv));
+    qemu_set_irq(readonly, sd->bdrv ? bdrv_is_read_only(sd->bdrv) : 0);
+    qemu_set_irq(insert, sd->bdrv ? bdrv_is_inserted(sd->bdrv) : 0);
 }
 
 static void sd_erase(SDState *sd)