diff options
author | Max Reitz <mreitz@redhat.com> | 2017-04-13 17:43:34 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2017-04-27 16:12:13 +0200 |
commit | de234897b60e034ba94b307fc289e2dc692c9251 (patch) | |
tree | 5778d41ef867df19810e33e7451f956e3b047d25 /block/blkreplay.c | |
parent | 24dfdfd0ff79ea094c41eb34d9acdc0a689d5617 (diff) |
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>
Diffstat (limited to 'block/blkreplay.c')
-rwxr-xr-x | block/blkreplay.c | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/block/blkreplay.c b/block/blkreplay.c index e1102119fb..6aa5fd4156 100755 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -37,9 +37,6 @@ static int blkreplay_open(BlockDriverState *bs, QDict *options, int flags, ret = 0; fail: - if (ret < 0) { - bdrv_unref_child(bs, bs->file); - } return ret; } |