]> git.proxmox.com Git - mirror_qemu.git/commitdiff
qcow2: Check bs->drv in copy_sectors()
authorMax Reitz <mreitz@redhat.com>
Mon, 10 Mar 2014 22:44:07 +0000 (23:44 +0100)
committerStefan Hajnoczi <stefanha@redhat.com>
Thu, 13 Mar 2014 13:23:27 +0000 (14:23 +0100)
Before dereferencing bs->drv for a call to its member bdrv_co_readv(),
copy_sectors() should check whether that pointer is indeed valid, since
it may have been set to NULL by e.g. a concurrent write triggering the
corruption prevention mechanism.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block/qcow2-cluster.c

index 36c1bed350bef91e9d8569b9038925dae42a6ea4..9499df9ef2d7ef022183ed1f4aa6bc5d38fbaf86 100644 (file)
@@ -380,6 +380,10 @@ static int coroutine_fn copy_sectors(BlockDriverState *bs,
 
     BLKDBG_EVENT(bs->file, BLKDBG_COW_READ);
 
+    if (!bs->drv) {
+        return -ENOMEDIUM;
+    }
+
     /* Call .bdrv_co_readv() directly instead of using the public block-layer
      * interface.  This avoids double I/O throttling and request tracking,
      * which can lead to deadlock when block layer copy-on-read is enabled.