]> git.proxmox.com Git - mirror_qemu.git/commit - block/qcow2.c
qcow2: Fix dangling pointer after reopen for 'file'
authorKevin Wolf <kwolf@redhat.com>
Thu, 8 Jul 2021 11:47:04 +0000 (13:47 +0200)
committerKevin Wolf <kwolf@redhat.com>
Fri, 9 Jul 2021 11:19:11 +0000 (13:19 +0200)
commitbcfd86d6a6432be75fd8700c7c1aabb243adf469
treec8c2aafd77c22ea17f8632a46715fcbec3517cd2
parenta7cd44bef3d9380181734a93977c3d1df3eef2cf
qcow2: Fix dangling pointer after reopen for 'file'

Without an external data file, s->data_file is a second pointer with the
same value as bs->file. When changing bs->file to a different BdrvChild
and freeing the old BdrvChild, s->data_file must also be updated,
otherwise it points to freed memory and causes crashes.

This problem was caught by iotests case 245.

Fixes: df2b7086f169239ebad5d150efa29c9bb6d4f820
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20210708114709.206487-2-kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qcow2.c