Skip to content

Commit 428e1b1

Browse files
adam900710kdave
authored andcommitted
Revert "btrfs: add ASSERTs on prealloc in qgroup functions"
This reverts commit 252877a. Commit 252877a ("btrfs: add ASSERTs on prealloc in qgroup functions") tries to remove the kfree() on preallocated qgroup during several call sites, but this cannot work as intended: - btrfs_quota_enable() - btrfs_create_qgroup() If add_qgroup_item() failed, we go out_free_path() and at that time prealloc is not yet utilized and will trigger the new ASSERT(). - btrfs_qgroup_inherit() If qgroup_auto_inherit() failed, prealloc is not yet utilized and will trigger the new ASSERT() Reported-by: syzbot+b44d4a4885bc82af2a06@syzkaller.appspotmail.com Link: https://lore.kernel.org/linux-btrfs/69369331.a70a0220.38f243.009e.GAE@google.com/ Signed-off-by: Qu Wenruo <wqu@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent 5630f75 commit 428e1b1

1 file changed

Lines changed: 4 additions & 23 deletions

File tree

fs/btrfs/qgroup.c

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,14 +1243,7 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info,
12431243
btrfs_end_transaction(trans);
12441244
else if (trans)
12451245
ret = btrfs_end_transaction(trans);
1246-
1247-
/*
1248-
* At this point we either failed at allocating prealloc, or we
1249-
* succeeded and passed the ownership to it to add_qgroup_rb(). In any
1250-
* case, this needs to be NULL or there is something wrong.
1251-
*/
1252-
ASSERT(prealloc == NULL);
1253-
1246+
kfree(prealloc);
12541247
return ret;
12551248
}
12561249

@@ -1682,12 +1675,7 @@ int btrfs_create_qgroup(struct btrfs_trans_handle *trans, u64 qgroupid)
16821675
ret = btrfs_sysfs_add_one_qgroup(fs_info, qgroup);
16831676
out:
16841677
mutex_unlock(&fs_info->qgroup_ioctl_lock);
1685-
/*
1686-
* At this point we either failed at allocating prealloc, or we
1687-
* succeeded and passed the ownership to it to add_qgroup_rb(). In any
1688-
* case, this needs to be NULL or there is something wrong.
1689-
*/
1690-
ASSERT(prealloc == NULL);
1678+
kfree(prealloc);
16911679
return ret;
16921680
}
16931681

@@ -3279,7 +3267,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
32793267
struct btrfs_root *quota_root;
32803268
struct btrfs_qgroup *srcgroup;
32813269
struct btrfs_qgroup *dstgroup;
3282-
struct btrfs_qgroup *prealloc = NULL;
3270+
struct btrfs_qgroup *prealloc;
32833271
struct btrfs_qgroup_list **qlist_prealloc = NULL;
32843272
bool free_inherit = false;
32853273
bool need_rescan = false;
@@ -3520,14 +3508,7 @@ int btrfs_qgroup_inherit(struct btrfs_trans_handle *trans, u64 srcid,
35203508
}
35213509
if (free_inherit)
35223510
kfree(inherit);
3523-
3524-
/*
3525-
* At this point we either failed at allocating prealloc, or we
3526-
* succeeded and passed the ownership to it to add_qgroup_rb(). In any
3527-
* case, this needs to be NULL or there is something wrong.
3528-
*/
3529-
ASSERT(prealloc == NULL);
3530-
3511+
kfree(prealloc);
35313512
return ret;
35323513
}
35333514

0 commit comments

Comments
 (0)