Skip to contentSkip to conversation

btrfs: qgroup: fix double unlock in btrfs_quota_disable

PATCH In review Boris Burkov 2 participants 2 messages Sep 27, 2023 Btrfs file system

lore
Share & tools
lore
#0 lore raw

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.

Fixes 5e99a45f1f0f ("btrfs: qgroup: flush reservations during quota disable")
---
 fs/btrfs/qgroup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/btrfs/qgroup.c +2 -1
index 1a486d8a7b5a..7d9cb7064811 100644
@@ -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
#1 lore raw
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.

Fixes 5e99a45f1f0f ("btrfs: qgroup: flush reservations during quota disable")

Folded to the commit, thanks.