Skip to content

Commit

Permalink
block: Fix Transaction leak in bdrv_root_attach_child()
Browse files Browse the repository at this point in the history
The error path needs to call tran_finalize(), too.

Fixes: CID 1452773
Fixes: 548a74c
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>
  • Loading branch information
kevmw committed May 18, 2021
1 parent 38b4409 commit e878bb1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions block.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit e878bb1

Please sign in to comment.