block: Fix Transaction leak in bdrv_root_attach_child()
The error path needs to call tran_finalize(), too.
Fixes: CID 1452773
Fixes: 548a74c0db
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20210503110555.24001-2-kwolf@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
38b4409647
commit
e878bb1293
7
block.c
7
block.c
@ -2916,13 +2916,14 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
|
|||||||
child_role, perm, shared_perm, opaque,
|
child_role, perm, shared_perm, opaque,
|
||||||
&child, tran, errp);
|
&child, tran, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
bdrv_unref(child_bs);
|
assert(child == NULL);
|
||||||
return NULL;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = bdrv_refresh_perms(child_bs, errp);
|
ret = bdrv_refresh_perms(child_bs, errp);
|
||||||
tran_finalize(tran, ret);
|
|
||||||
|
|
||||||
|
out:
|
||||||
|
tran_finalize(tran, ret);
|
||||||
bdrv_unref(child_bs);
|
bdrv_unref(child_bs);
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user