summaryrefslogtreecommitdiff
path: root/fs/bcachefs/fsck.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-07-21 02:30:53 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-23 00:10:08 +0300
commit2a89a3e9682b127c1978ac31eb38ef73a39a416e (patch)
tree7b61ce1a130c78ef8866299d87546db0ed915aca /fs/bcachefs/fsck.c
parent8e992c6c1f3869d0b33c754d4b6730603d3586c4 (diff)
downloadlinux-2a89a3e9682b127c1978ac31eb38ef73a39a416e.tar.xz
bcachefs: Fix a null ptr deref in check_xattr()
We were attempting to initialize inode hash info when no inodes were found. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/fsck.c')
-rw-r--r--fs/bcachefs/fsck.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/bcachefs/fsck.c b/fs/bcachefs/fsck.c
index 022af0270692..5338765b3e68 100644
--- a/fs/bcachefs/fsck.c
+++ b/fs/bcachefs/fsck.c
@@ -1662,7 +1662,7 @@ static int check_dirent(struct btree_trans *trans, struct btree_iter *iter,
if (ret < 0)
goto err;
- if (dir->first_this_inode)
+ if (dir->first_this_inode && dir->inodes.nr)
*hash_info = bch2_hash_info_init(c, &dir->inodes.data[0].inode);
dir->first_this_inode = false;
@@ -1839,7 +1839,7 @@ static int check_xattr(struct btree_trans *trans, struct btree_iter *iter,
if (ret)
return ret;
- if (inode->first_this_inode)
+ if (inode->first_this_inode && inode->inodes.nr)
*hash_info = bch2_hash_info_init(c, &inode->inodes.data[0].inode);
inode->first_this_inode = false;