diff mbox series

[for,5.0] block: fix bdrv_root_attach_child forget to unref child_bs

Message ID 20200324155921.23822-1-vsementsov@virtuozzo.com (mailing list archive)
State New, archived
Headers show
Series [for,5.0] block: fix bdrv_root_attach_child forget to unref child_bs | expand

Commit Message

Vladimir Sementsov-Ogievskiy March 24, 2020, 3:59 p.m. UTC
bdrv_root_attach_child promises to drop child_bs reference on failure.
It does it on first handled failure path, but not on the second. Fix
that.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Kevin Wolf March 24, 2020, 4:10 p.m. UTC | #1
Am 24.03.2020 um 16:59 hat Vladimir Sementsov-Ogievskiy geschrieben:
> bdrv_root_attach_child promises to drop child_bs reference on failure.
> It does it on first handled failure path, but not on the second. Fix
> that.
> 
> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>

Thanks, applied to the block branch.

Kevin
diff mbox series

Patch

diff --git a/block.c b/block.c
index a2542c977b..6713db773d 100644
--- a/block.c
+++ b/block.c
@@ -2612,6 +2612,7 @@  BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
             error_propagate(errp, local_err);
             g_free(child);
             bdrv_abort_perm_update(child_bs);
+            bdrv_unref(child_bs);
             return NULL;
         }
     }