Commit b9b8a41a authored by Dan Carpenter's avatar Dan Carpenter Committed by David Sterba
Browse files

btrfs: use after free in btrfs_quota_enable

The issue here is that btrfs_commit_transaction() frees "trans" on both
the error and the success path.  So the problem would be if
btrfs_commit_transaction() succeeds, and then qgroup_rescan_init()
fails.  That means that "ret" is non-zero and "trans" is non-NULL and it
leads to a use after free inside the btrfs_end_transaction() macro.

Fixes: 340f1aa2

 ("btrfs: qgroups: Move transaction management inside btrfs_quota_enable/disable")
Signed-off-by: default avatarDan Carpenter <>
Reviewed-by: default avatarNikolay Borisov <>
Reviewed-by: default avatarDavid Sterba <>
Signed-off-by: default avatarDavid Sterba <>
parent 801660b0
......@@ -1019,10 +1019,9 @@ out_add_root:
ret = btrfs_commit_transaction(trans);
if (ret) {
trans = NULL;
trans = NULL;
if (ret)
goto out_free_path;
ret = qgroup_rescan_init(fs_info, 0, 1);
if (!ret) {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment