]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/extra/0003-block-Do-not-unref-bs-file-on-error-in-BD-s-open.patch
bump version to 2.9.0-5
[pve-qemu.git] / debian / patches / extra / 0003-block-Do-not-unref-bs-file-on-error-in-BD-s-open.patch
CommitLineData
e74c0f31 1From 80a3ed331899e4710b33c4b2a88f1b7b888d6497 Mon Sep 17 00:00:00 2001
90a6d957
WB
2From: Max Reitz <mreitz@redhat.com>
3Date: Thu, 13 Apr 2017 17:43:34 +0200
e74c0f31 4Subject: [PATCH 03/23] block: Do not unref bs->file on error in BD's open
90a6d957
WB
5
6The block layer takes care of removing the bs->file child if the block
7driver's bdrv_open()/bdrv_file_open() implementation fails. The block
8driver therefore does not need to do so, and indeed should not unless it
9sets bs->file to NULL afterwards -- because if this is not done, the
10bdrv_unref_child() in bdrv_open_inherit() will dereference the freed
11memory block at bs->file afterwards, which is not good.
12
13We can now decide whether to add a "bs->file = NULL;" after each of the
14offending bdrv_unref_child() invocations, or just drop them altogether.
15The latter is simpler, so let's do that.
16
17Cc: qemu-stable <qemu-stable@nongnu.org>
18Signed-off-by: Max Reitz <mreitz@redhat.com>
19Reviewed-by: Eric Blake <eblake@redhat.com>
20Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
21Signed-off-by: Kevin Wolf <kwolf@redhat.com>
22---
23 block/blkdebug.c | 4 +---
24 block/blkreplay.c | 3 ---
25 block/blkverify.c | 3 ---
26 3 files changed, 1 insertion(+), 9 deletions(-)
27
28diff --git a/block/blkdebug.c b/block/blkdebug.c
29index 67e8024e36..cc4a146e84 100644
30--- a/block/blkdebug.c
31+++ b/block/blkdebug.c
32@@ -389,14 +389,12 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags,
33 } else if (align) {
34 error_setg(errp, "Invalid alignment");
35 ret = -EINVAL;
36- goto fail_unref;
37+ goto out;
38 }
39
40 ret = 0;
41 goto out;
42
43-fail_unref:
44- bdrv_unref_child(bs, bs->file);
45 out:
46 if (ret < 0) {
47 g_free(s->config_file);
48diff --git a/block/blkreplay.c b/block/blkreplay.c
49index e1102119fb..6aa5fd4156 100755
50--- a/block/blkreplay.c
51+++ b/block/blkreplay.c
52@@ -37,9 +37,6 @@ static int blkreplay_open(BlockDriverState *bs, QDict *options, int flags,
53
54 ret = 0;
55 fail:
56- if (ret < 0) {
57- bdrv_unref_child(bs, bs->file);
58- }
59 return ret;
60 }
61
62diff --git a/block/blkverify.c b/block/blkverify.c
63index 9a1e21c6ad..af23281669 100644
64--- a/block/blkverify.c
65+++ b/block/blkverify.c
66@@ -142,9 +142,6 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags,
67
68 ret = 0;
69 fail:
70- if (ret < 0) {
71- bdrv_unref_child(bs, bs->file);
72- }
73 qemu_opts_del(opts);
74 return ret;
75 }
76--
772.11.0
78