]> git.proxmox.com Git - qemu.git/commitdiff
Don't allow multiwrites against a block device without underlying medium
authorRyan Harper <ryanh@us.ibm.com>
Mon, 7 Mar 2011 16:01:04 +0000 (10:01 -0600)
committerJustin M. Forbes <jforbes@redhat.com>
Mon, 4 Apr 2011 19:24:29 +0000 (14:24 -0500)
If the block device has been closed, we no longer have a medium to submit
IO against, check for this before submitting io.  This prevents a segfault
further in the code where we dereference elements of the block driver.

Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c

diff --git a/block.c b/block.c
index b476479e0dc9c1cb1f659c4a5db1af9e3e1005e3..17de165a5bd78428458b0ec9e0a68366f2d04a20 100644 (file)
--- a/block.c
+++ b/block.c
@@ -2295,6 +2295,14 @@ int bdrv_aio_multiwrite(BlockDriverState *bs, BlockRequest *reqs, int num_reqs)
     MultiwriteCB *mcb;
     int i;
 
+    /* don't submit writes if we don't have a medium */
+    if (bs->drv == NULL) {
+        for (i = 0; i < num_reqs; i++) {
+            reqs[i].error = -ENOMEDIUM;
+        }
+        return -1;
+    }
+
     if (num_reqs == 0) {
         return 0;
     }