[PATCH v2 12/33] block/copy-before-write: drop extra bdrv_unref on failure path

Vladimir Sementsov-Ogievskiy posted 33 patches 3 years, 5 months ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Max Reitz <mreitz@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Cleber Rosa <crosa@redhat.com>, Eric Blake <eblake@redhat.com>, John Snow <jsnow@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, Markus Armbruster <armbru@redhat.com>, Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
There is a newer version of this series
[PATCH v2 12/33] block/copy-before-write: drop extra bdrv_unref on failure path
Posted by Vladimir Sementsov-Ogievskiy 3 years, 5 months ago
bdrv_attach_child() do bdrv_unref() on failure, so we shouldn't do it
by hand here.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/copy-before-write.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/block/copy-before-write.c b/block/copy-before-write.c
index 2a51cc64e4..945d9340f4 100644
--- a/block/copy-before-write.c
+++ b/block/copy-before-write.c
@@ -201,7 +201,6 @@ BlockDriverState *bdrv_cbw_append(BlockDriverState *source,
     state->target = bdrv_attach_child(top, target, "target", &child_of_bds,
                                       BDRV_CHILD_DATA, errp);
     if (!state->target) {
-        bdrv_unref(target);
         bdrv_unref(top);
         return NULL;
     }
-- 
2.29.2


Re: [PATCH v2 12/33] block/copy-before-write: drop extra bdrv_unref on failure path
Posted by Max Reitz 3 years, 5 months ago
On 20.05.21 16:21, Vladimir Sementsov-Ogievskiy wrote:
> bdrv_attach_child() do bdrv_unref() on failure, so we shouldn't do it
> by hand here.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> ---
>   block/copy-before-write.c | 1 -
>   1 file changed, 1 deletion(-)

Reviewed-by: Max Reitz <mreitz@redhat.com>