aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Reitz <mreitz@redhat.com>2014-03-10 23:44:07 +0100
committerStefan Hajnoczi <stefanha@redhat.com>2014-03-13 14:23:27 +0100
commitdba2855572c746836ad90ce9154403b5929d996b (patch)
treee6f4d87aca3c7b9d74ebc6cacbba7040f4f6d8cb
parent3456a8d1852e970688b73d03fdc44dde851759e1 (diff)
downloadqemu-dba2855572c746836ad90ce9154403b5929d996b.zip
qemu-dba2855572c746836ad90ce9154403b5929d996b.tar.gz
qemu-dba2855572c746836ad90ce9154403b5929d996b.tar.bz2
qcow2: Check bs->drv in copy_sectors()
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>
-rw-r--r--block/qcow2-cluster.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 36c1bed..9499df9 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -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.