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:
Kevin Wolf 2021-05-03 13:05:54 +02:00
parent 38b4409647
commit e878bb1293

View File

@ -2916,13 +2916,14 @@ BdrvChild *bdrv_root_attach_child(BlockDriverState *child_bs,
child_role, perm, shared_perm, opaque,
&child, tran, errp);
if (ret < 0) {
bdrv_unref(child_bs);
return NULL;
assert(child == NULL);
goto out;
}
ret = bdrv_refresh_perms(child_bs, errp);
tran_finalize(tran, ret);
out:
tran_finalize(tran, ret);
bdrv_unref(child_bs);
return child;
}