]> git.proxmox.com Git - mirror_qemu.git/commit
block: Do not unref bs->file on error in BD's open
authorMax Reitz <mreitz@redhat.com>
Thu, 13 Apr 2017 15:43:34 +0000 (17:43 +0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Mon, 31 Jul 2017 21:44:54 +0000 (16:44 -0500)
commitc1059a3a3cb80bc087ad7e33fced4f8a7a9c0150
tree622a94a2446f588db967efbe662188ec01b5ea5a
parent0b906e4d0ab270afda5de71977a84801e1ffac1d
block: Do not unref bs->file on error in BD's open

The block layer takes care of removing the bs->file child if the block
driver's bdrv_open()/bdrv_file_open() implementation fails. The block
driver therefore does not need to do so, and indeed should not unless it
sets bs->file to NULL afterwards -- because if this is not done, the
bdrv_unref_child() in bdrv_open_inherit() will dereference the freed
memory block at bs->file afterwards, which is not good.

We can now decide whether to add a "bs->file = NULL;" after each of the
offending bdrv_unref_child() invocations, or just drop them altogether.
The latter is simpler, so let's do that.

Cc: qemu-stable <qemu-stable@nongnu.org>
Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
(cherry picked from commit de234897b60e034ba94b307fc289e2dc692c9251)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
block/blkdebug.c
block/blkreplay.c
block/blkverify.c