From: Vladimir Sementsov-Ogievskiy Date: Mon, 16 Mar 2020 06:06:31 +0000 (+0300) Subject: block/qcow2: zero data_file child after free X-Git-Tag: qemu-xen-4.14.0~54^2~2 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=808cf3cb6af8171b4e24d24f2a2d461434dc6572;p=qemu-xen.git block/qcow2: zero data_file child after free data_file being NULL doesn't seem to be a correct state, but it's better than dead pointer and simpler to debug. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20200316060631.30052-3-vsementsov@virtuozzo.com> Reviewed-by: John Snow Signed-off-by: Max Reitz --- diff --git a/block/qcow2.c b/block/qcow2.c index e08917ed84..d1da3d91db 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1758,6 +1758,7 @@ static int coroutine_fn qcow2_do_open(BlockDriverState *bs, QDict *options, g_free(s->image_data_file); if (has_data_file(bs)) { bdrv_unref_child(bs, s->data_file); + s->data_file = NULL; } g_free(s->unknown_header_fields); cleanup_unknown_header_ext(bs); @@ -2621,6 +2622,7 @@ static void qcow2_close(BlockDriverState *bs) if (has_data_file(bs)) { bdrv_unref_child(bs, s->data_file); + s->data_file = NULL; } qcow2_refcount_close(bs);