Konstantin Demin
8cbaf1dea2
3rd patchs (in alphabetical order): - bbr3 - ntsync5 - openwrt - pf-kernel - xanmod - zen no configuration changes for now
55 lines
1.7 KiB
Diff
55 lines
1.7 KiB
Diff
From ed73b9279db9536a9672cba6506950c26cedb140 Mon Sep 17 00:00:00 2001
|
|
From: Yue Haibing <yuehaibing@huawei.com>
|
|
Date: Tue, 22 Oct 2024 17:52:08 +0800
|
|
Subject: btrfs: fix passing 0 to ERR_PTR in btrfs_search_dir_index_item()
|
|
|
|
The ret may be zero in btrfs_search_dir_index_item() and should not
|
|
passed to ERR_PTR(). Now btrfs_unlink_subvol() is the only caller to
|
|
this, reconstructed it to check ERR_PTR(-ENOENT) while ret >= 0.
|
|
|
|
This fixes smatch warnings:
|
|
|
|
fs/btrfs/dir-item.c:353
|
|
btrfs_search_dir_index_item() warn: passing zero to 'ERR_PTR'
|
|
|
|
Fixes: 9dcbe16fccbb ("btrfs: use btrfs_for_each_slot in btrfs_search_dir_index_item")
|
|
CC: stable@vger.kernel.org # 6.1+
|
|
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
|
|
Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
|
|
Reviewed-by: David Sterba <dsterba@suse.com>
|
|
Signed-off-by: David Sterba <dsterba@suse.com>
|
|
---
|
|
fs/btrfs/dir-item.c | 4 ++--
|
|
fs/btrfs/inode.c | 7 ++-----
|
|
2 files changed, 4 insertions(+), 7 deletions(-)
|
|
|
|
--- a/fs/btrfs/dir-item.c
|
|
+++ b/fs/btrfs/dir-item.c
|
|
@@ -347,8 +347,8 @@ btrfs_search_dir_index_item(struct btrfs
|
|
return di;
|
|
}
|
|
/* Adjust return code if the key was not found in the next leaf. */
|
|
- if (ret > 0)
|
|
- ret = 0;
|
|
+ if (ret >= 0)
|
|
+ ret = -ENOENT;
|
|
|
|
return ERR_PTR(ret);
|
|
}
|
|
--- a/fs/btrfs/inode.c
|
|
+++ b/fs/btrfs/inode.c
|
|
@@ -4344,11 +4344,8 @@ static int btrfs_unlink_subvol(struct bt
|
|
*/
|
|
if (btrfs_ino(inode) == BTRFS_EMPTY_SUBVOL_DIR_OBJECTID) {
|
|
di = btrfs_search_dir_index_item(root, path, dir_ino, &fname.disk_name);
|
|
- if (IS_ERR_OR_NULL(di)) {
|
|
- if (!di)
|
|
- ret = -ENOENT;
|
|
- else
|
|
- ret = PTR_ERR(di);
|
|
+ if (IS_ERR(di)) {
|
|
+ ret = PTR_ERR(di);
|
|
btrfs_abort_transaction(trans, ret);
|
|
goto out;
|
|
}
|