diff options
author | Max Reitz <mreitz@redhat.com> | 2014-08-07 22:47:55 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-08-15 15:07:16 +0200 |
commit | 908bcd540f489f7adf2d804347905b0025d808d3 (patch) | |
tree | 9f4b14955426dfa57bcfb940fb46e3ba5d4b3c47 /block.c | |
parent | a42f8a3d05c5598cee893c9cf5ffeee48bacb83e (diff) | |
download | qemu-908bcd540f489f7adf2d804347905b0025d808d3.zip qemu-908bcd540f489f7adf2d804347905b0025d808d3.tar.gz qemu-908bcd540f489f7adf2d804347905b0025d808d3.tar.bz2 |
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 <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r-- | block.c | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -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; } |