qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] check for bs->drv in bdrv_flush
@ 2009-03-28 18:39 Christoph Hellwig
  2009-03-29  1:32 ` Anthony Liguori
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2009-03-28 18:39 UTC (permalink / raw)
  To: qemu-devel

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>

Index: qemu/block.c
===================================================================
--- qemu.orig/block.c	2009-03-19 21:48:12.180978074 +0100
+++ qemu/block.c	2009-03-19 21:48:53.228977807 +0100
@@ -979,6 +979,8 @@ const char *bdrv_get_device_name(BlockDr
 
 void bdrv_flush(BlockDriverState *bs)
 {
+    if (!bs->drv)
+        return;
     if (bs->drv->bdrv_flush)
         bs->drv->bdrv_flush(bs);
     if (bs->backing_hd)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-03-29  7:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-28 18:39 [Qemu-devel] [PATCH] check for bs->drv in bdrv_flush Christoph Hellwig
2009-03-29  1:32 ` Anthony Liguori
2009-03-29  7:31   ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).