diff mbox series

ufs: Remove redundant inode number check from ufs_nfs_get_inode

Message ID 20240822142610.129668-1-sergii.boryshchenko@globallogic.com (mailing list archive)
State New
Headers show
Series ufs: Remove redundant inode number check from ufs_nfs_get_inode | expand

Commit Message

Sergii Boryshchenko Aug. 22, 2024, 2:26 p.m. UTC
From: Sergii Boryshchenko <sergii.boryshchenko@globallogic.com>

The `ufs_nfs_get_inode` function contains a check to validate the inode number
(`ino`) against the valid range of inode numbers. However, this check is
redundant because the same validation is already performed in the `ufs_iget`
function, which is called immediately afterward.

By removing this redundant check, we simplify the code and avoid unnecessary
double-checking of the inode number, while still ensuring that invalid inode
numbers are properly handled by the `ufs_iget` function.

This change has no impact on the functionality since `ufs_iget` provides the
necessary validation for all callers.

Signed-off-by: Sergii Boryshchenko <sergii.boryshchenko@globallogic.com>
---
 fs/ufs/super.c | 3 ---
 1 file changed, 3 deletions(-)

Comments

kernel test robot Aug. 26, 2024, 9:12 a.m. UTC | #1
Hi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on viro-vfs/for-next v6.11-rc5 next-20240823]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/sergii-boryshchenko-globallogic-com/ufs-Remove-redundant-inode-number-check-from-ufs_nfs_get_inode/20240826-120030
base:   linus/master
patch link:    https://lore.kernel.org/r/20240822142610.129668-1-sergii.boryshchenko%40globallogic.com
patch subject: [PATCH] ufs: Remove redundant inode number check from ufs_nfs_get_inode
config: arc-randconfig-001-20240826 (https://download.01.org/0day-ci/archive/20240826/202408261605.ARxTA9jX-lkp@intel.com/config)
compiler: arc-elf-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240826/202408261605.ARxTA9jX-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408261605.ARxTA9jX-lkp@intel.com/

All warnings (new ones prefixed by >>):

   fs/ufs/super.c: In function 'ufs_nfs_get_inode':
>> fs/ufs/super.c:101:37: warning: unused variable 'uspi' [-Wunused-variable]
     101 |         struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
         |                                     ^~~~


vim +/uspi +101 fs/ufs/super.c

^1da177e4c3f41 Linus Torvalds  2005-04-16   98  
f3e2a520f5fb1a Alexey Dobriyan 2009-12-15   99  static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 generation)
f3e2a520f5fb1a Alexey Dobriyan 2009-12-15  100  {
f3e2a520f5fb1a Alexey Dobriyan 2009-12-15 @101  	struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
f3e2a520f5fb1a Alexey Dobriyan 2009-12-15  102  	struct inode *inode;
f3e2a520f5fb1a Alexey Dobriyan 2009-12-15  103  
f3e2a520f5fb1a Alexey Dobriyan 2009-12-15  104  	inode = ufs_iget(sb, ino);
f3e2a520f5fb1a Alexey Dobriyan 2009-12-15  105  	if (IS_ERR(inode))
f3e2a520f5fb1a Alexey Dobriyan 2009-12-15  106  		return ERR_CAST(inode);
f3e2a520f5fb1a Alexey Dobriyan 2009-12-15  107  	if (generation && inode->i_generation != generation) {
f3e2a520f5fb1a Alexey Dobriyan 2009-12-15  108  		iput(inode);
f3e2a520f5fb1a Alexey Dobriyan 2009-12-15  109  		return ERR_PTR(-ESTALE);
f3e2a520f5fb1a Alexey Dobriyan 2009-12-15  110  	}
f3e2a520f5fb1a Alexey Dobriyan 2009-12-15  111  	return inode;
f3e2a520f5fb1a Alexey Dobriyan 2009-12-15  112  }
f3e2a520f5fb1a Alexey Dobriyan 2009-12-15  113
diff mbox series

Patch

diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index bc625788589c..11e8b869e0ba 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -101,9 +101,6 @@  static struct inode *ufs_nfs_get_inode(struct super_block *sb, u64 ino, u32 gene
 	struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi;
 	struct inode *inode;
 
-	if (ino < UFS_ROOTINO || ino > (u64)uspi->s_ncg * uspi->s_ipg)
-		return ERR_PTR(-ESTALE);
-
 	inode = ufs_iget(sb, ino);
 	if (IS_ERR(inode))
 		return ERR_CAST(inode);