Skip to content

Commit 352349a

Browse files
fdmananagregkh
authored andcommitted
btrfs: check for error when looking up inode during dir entry replay
commit cfd3126 upstream. At replay_one_name(), we are treating any error from btrfs_lookup_inode() as if the inode does not exists. Fix this by checking for an error and returning it to the caller. CC: stable@vger.kernel.org # 4.14+ Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4ed6847 commit 352349a

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

‎fs/btrfs/tree-log.c‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,8 +1902,8 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
19021902
struct btrfs_key log_key;
19031903
struct inode *dir;
19041904
u8 log_type;
1905-
int exists;
1906-
int ret = 0;
1905+
bool exists;
1906+
int ret;
19071907
bool update_size = (key->type == BTRFS_DIR_INDEX_KEY);
19081908
bool name_added = false;
19091909

@@ -1923,12 +1923,12 @@ static noinline int replay_one_name(struct btrfs_trans_handle *trans,
19231923
name_len);
19241924

19251925
btrfs_dir_item_key_to_cpu(eb, di, &log_key);
1926-
exists = btrfs_lookup_inode(trans, root, path, &log_key, 0);
1927-
if (exists == 0)
1928-
exists = 1;
1929-
else
1930-
exists = 0;
1926+
ret = btrfs_lookup_inode(trans, root, path, &log_key, 0);
19311927
btrfs_release_path(path);
1928+
if (ret < 0)
1929+
goto out;
1930+
exists = (ret == 0);
1931+
ret = 0;
19321932

19331933
if (key->type == BTRFS_DIR_ITEM_KEY) {
19341934
dst_di = btrfs_lookup_dir_item(trans, root, path, key->objectid,

0 commit comments

Comments
 (0)