From 908bcd540f489f7adf2d804347905b0025d808d3 Mon Sep 17 00:00:00 2001 From: Max Reitz Date: Thu, 7 Aug 2014 22:47:55 +0200 Subject: block: Catch !bs->drv in bdrv_check() qemu-img check calls bdrv_check() twice if the first run repaired some inconsistencies. If the first run however again triggered corruption prevention (on qcow2) due to very bad inconsistencies, bs->drv may be NULL afterwards. Thus, bdrv_check() should check whether bs->drv is set. Signed-off-by: Max Reitz Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'block.c') diff --git a/block.c b/block.c index 6ef3465b4a..6fa0201074 100644 --- a/block.c +++ b/block.c @@ -2209,6 +2209,9 @@ bool bdrv_dev_is_medium_locked(BlockDriverState *bs) */ int bdrv_check(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix) { + if (bs->drv == NULL) { + return -ENOMEDIUM; + } if (bs->drv->bdrv_check == NULL) { return -ENOTSUP; } -- cgit v1.2.3