Skip to contentSkip to conversation

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

Qemu-devel Anthony Liguori 1 participant 1 message Mar 29, 2009

lore
Share & tools
lore
#0 lore raw

Revision: 6943

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6943
Author:   aliguori
Date:     2009-03-29 01:31:51 +0000 (Sun, 29 Mar 2009)

Log Message:
-----------
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.

Modified Paths:
--------------
trunk/block.c

Modified: trunk/block.c
===================================================================

block.c +2 -0
@@ -1002,6 +1002,8 @@
 
 void bdrv_flush(BlockDriverState *bs)
 {
+    if (!bs->drv)
+        return;
     if (bs->drv->bdrv_flush)
         bs->drv->bdrv_flush(bs);
     if (bs->backing_hd)