btrfs: qgroup: fix double unlock in btrfs_quota_disable
PATCH 1/1 btrfs: qgroup: fix double unlock in btrfs_quota_disable
Flushing reservations in quota disable is done while we do not hold the qgroup ioctl lock, therefore jumping to releasing that lock on failure is wrong. We don't have the transaction handle yet, either, so just jump to unlocking the cleaner mutex. This was found by smatch.
Reported-by Dan Carpenter <[email protected]>
Fixes 5e99a45f1f0f ("btrfs: qgroup: flush reservations during quota disable")
Signed-off-by Boris Burkov <[email protected]>
--- fs/btrfs/qgroup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/qgroup.c +2 -1
@@ -1375,7 +1375,7 @@ int btrfs_quota_disable(struct btrfs_fs_info *fs_info) ret =flush_reservations (fs_info);if (ret) - goto out; + goto unlock_cleaner;/* * 1 For the root item
@@ -1439,6 +1439,7 @@ int btrfs_quota_disable(struct btrfs_fs_info *fs_info)btrfs_end_transaction (trans); else if (trans) ret =btrfs_commit_transaction (trans); +unlock_cleaner:mutex_unlock (&fs_info->cleaner_mutex);return ret;
Signature · 1 line
2.42.0
Quoted 9 lines · Boris Burkov
Flushing reservations in quota disable is done while we do not hold the qgroup ioctl lock, therefore jumping to releasing that lock on failure is wrong. We don't have the transaction handle yet, either, so just jump to unlocking the cleaner mutex. This was found by smatch.
Reported-by Dan Carpenter <[email protected]>Fixes 5e99a45f1f0f ("btrfs: qgroup: flush reservations during quota disable")Signed-off-by Boris Burkov <[email protected]>
Folded to the commit, thanks.