When the list of reloc_roots is empty, no error return code of
btrfs_recover_relocation() is assigned.
To fix this bug, err is assigned with -ENOENT as error return code.

Reported-by: TOTE Robot <os...@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1...@gmail.com>
---
 fs/btrfs/relocation.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 232d5da7b7be..631b672a852f 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -3817,8 +3817,10 @@ int btrfs_recover_relocation(struct btrfs_root *root)
        }
        btrfs_release_path(path);
 
-       if (list_empty(&reloc_roots))
+       if (list_empty(&reloc_roots)) {
+               err = -ENOENT;
                goto out;
+       }
 
        rc = alloc_reloc_control(fs_info);
        if (!rc) {
-- 
2.17.1

Reply via email to