aboutsummaryrefslogtreecommitdiff
path: root/block/quorum.c
diff options
context:
space:
mode:
authorAlberto Garcia <berto@igalia.com>2019-05-13 16:46:18 +0300
committerMax Reitz <mreitz@redhat.com>2019-05-28 20:30:55 +0200
commitb441dc71c0b7e8f488a6ebc2aa781b08a3a05038 (patch)
treedd5875c418d32a8fb09dab833cd5e5921b56e325 /block/quorum.c
parentdd4118c792a8c2a104fe90274e8a41e0db1ebc56 (diff)
downloadqemu-b441dc71c0b7e8f488a6ebc2aa781b08a3a05038.zip
qemu-b441dc71c0b7e8f488a6ebc2aa781b08a3a05038.tar.gz
qemu-b441dc71c0b7e8f488a6ebc2aa781b08a3a05038.tar.bz2
block: Make bdrv_root_attach_child() unref child_bs on failure
A consequence of the previous patch is that bdrv_attach_child() transfers the reference to child_bs from the caller to parent_bs, which will drop it on bdrv_close() or when someone calls bdrv_unref_child(). But this only happens when bdrv_attach_child() succeeds. If it fails then the caller is responsible for dropping the reference to child_bs. This patch makes bdrv_attach_child() take the reference also when there is an error, freeing the caller for having to do it. A similar situation happens with bdrv_root_attach_child(), so the changes on this patch affect both functions. Signed-off-by: Alberto Garcia <berto@igalia.com> Message-id: 20dfb3d9ccec559cdd1a9690146abad5d204a186.1557754872.git.berto@igalia.com [mreitz: Removed now superfluous BdrvChild * variable in bdrv_open_child()] Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'block/quorum.c')
-rw-r--r--block/quorum.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/block/quorum.c b/block/quorum.c
index 352f729..133ee18 100644
--- a/block/quorum.c
+++ b/block/quorum.c
@@ -1019,7 +1019,6 @@ static void quorum_add_child(BlockDriverState *bs, BlockDriverState *child_bs,
child = bdrv_attach_child(bs, child_bs, indexstr, &child_format, errp);
if (child == NULL) {
s->next_child_index--;
- bdrv_unref(child_bs);
goto out;
}
s->children = g_renew(BdrvChild *, s->children, s->num_children + 1);