Commit 081501daceca74d2091e798d5dcd342c14d66d1a

Authored by aliguori
1 parent 999dec57

check for bs->drv in bdrv_flush (Christoph Hellwig)

All the bdrv_ helpers should check for bs->drv being zero as that means
there is no backend image open.  bdrv_flush fails to perform that check
and can thus cause NULL pointer dereferences.

Found using qemu-io.


Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6943 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 2 additions and 0 deletions
... ... @@ -1002,6 +1002,8 @@ const char *bdrv_get_device_name(BlockDriverState *bs)
1002 1002  
1003 1003 void bdrv_flush(BlockDriverState *bs)
1004 1004 {
  1005 + if (!bs->drv)
  1006 + return;
1005 1007 if (bs->drv->bdrv_flush)
1006 1008 bs->drv->bdrv_flush(bs);
1007 1009 if (bs->backing_hd)
... ...