]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
block/qcow2: zero data_file child after free
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Mon, 16 Mar 2020 06:06:31 +0000 (09:06 +0300)
committerMax Reitz <mreitz@redhat.com>
Tue, 24 Mar 2020 10:41:46 +0000 (11:41 +0100)
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 <vsementsov@virtuozzo.com>
Message-Id: <20200316060631.30052-3-vsementsov@virtuozzo.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
block/qcow2.c

index e08917ed84623291385ddb083818c17d07f7f298..d1da3d91db21e8fc91f8c116255c32abf9cf86d2 100644 (file)
@@ -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);