Skip to content

Commit

Permalink
block: Catch !bs->drv in bdrv_check()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
XanClic authored and kevmw committed Aug 15, 2014
1 parent a42f8a3 commit 908bcd5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions block.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 908bcd5

Please sign in to comment.