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>
This commit is contained in:
Stefan Hajnoczi 2010-04-17 10:49:06 +01:00 committed by Kevin Wolf
parent 6511ef7737
commit 557df6aca2
1 changed files with 3 additions and 1 deletions

View File

@ -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