aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Hajnoczi <stefanha@linux.vnet.ibm.com>2010-04-17 10:49:06 +0100
committerKevin Wolf <kwolf@redhat.com>2010-05-03 10:07:31 +0200
commit557df6aca2e389ef631b283ca1522b1fdf121eff (patch)
tree72bc4c6bd08e24bd7ee1c705260f4a227fa9be4c
parent6511ef77375100ecf9134f85f08cef31fd196cdf (diff)
block: Set backing_hd to NULL after deleting it
It is safer to set backing_hd to NULL after deleting it so that any use after deletion is obvious during development. Happy segfaulting! This patch should be applied after Kevin Wolf's "vmdk: Convert to bdrv_open" so that vmdk does not segfault on close. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r--block.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/block.c b/block.c
index 56835afc56..b318355175 100644
--- a/block.c
+++ b/block.c
@@ -589,8 +589,10 @@ unlink_and_fail:
void bdrv_close(BlockDriverState *bs)
{
if (bs->drv) {
- if (bs->backing_hd)
+ if (bs->backing_hd) {
bdrv_delete(bs->backing_hd);
+ bs->backing_hd = NULL;
+ }
bs->drv->bdrv_close(bs);
qemu_free(bs->opaque);
#ifdef _WIN32