btrfs: inode: Check if we get a valid inode before checking its mode.
PATCH 1/1 btrfs: inode: Check if we get a valid inode before checking its mode.
We should check the inode validation before checking the imode.
As btrfs_iget() could return ERR_PTR(), unlike previous path, we need to verify the inode before checking the imode.
---
To David:
Please fold this into 9944a5b5d26e ("btrfs: inode: Verify inode mode to avoid NULL pointer dereference") of misc-next branch.
--- fs/btrfs/inode.c | 2 ++ 1 file changed, 2 insertions(+)
fs/btrfs/inode.c +2 -0
@@ -5776,6 +5776,8 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)if (location.type ==BTRFS_INODE_ITEM_KEY ) { inode =btrfs_iget (dir->i_sb, &location, root,NULL ); +if (IS_ERR (inode)) +return inode;/* Do extra check against inode mode with di_type */ if (btrfs_inode_type (inode) != di_type) {
Signature · 1 line
2.21.0
Quoted 6 lines · Qu Wenruo
We should check the inode validation before checking the imode.
As
btrfs_iget()could returnERR_PTR(), unlike previous path, we need to verify the inode before checking the imode.Signed-off-by Qu Wenruo <[email protected]>
Quoted 23 lines
---
To David:Please fold this into
9944a5b5d26e("btrfs: inode: Verify inode mode to avoid NULL pointer dereference") of misc-next branch.--- fs/btrfs/inode.c | 2 ++ 1 file changed, 2 insertions(+)fs/btrfs/inode.c +2
-0@@ -5776,6 +5776,8 @@ struct inode *btrfs_lookup_dentry(struct inode *dir, struct dentry *dentry)if (location.type ==BTRFS_INODE_ITEM_KEY ) { inode =btrfs_iget (dir->i_sb, &location, root,NULL ); +if (IS_ERR (inode)) +return inode;/* Do extra check against inode mode with di_type */ if (btrfs_inode_type (inode) != di_type) {
Quoted 11 lines · Qu Wenruo
We should check the inode validation before checking the imode.
As
btrfs_iget()could returnERR_PTR(), unlike previous path, we need to verify the inode before checking the imode.Signed-off-by Qu Wenruo <[email protected]>---
To David:Please fold this into
9944a5b5d26e("btrfs: inode: Verify inode mode to avoid NULL pointer dereference") of misc-next branch.
Folded and branch pushed, thanks.