[viro-vfs:work.dcache-misc 10/18] fs/dcache.c:2062 __d_obtain_alias() warn: variable dereferenced before check 'inode' (see line 2059)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git work.dcache-misc
head:   0695819b3988e7e4d8099f8388244c1549d230cc
commit: 8a0af412cf8ba3a000a0e00c0c5dd411b9a0fc2a [10/18] kill d_instantate_anon(), fold __d_instantiate_anon() into remaining caller
config: i386-randconfig-141-20231124 (https://download.01.org/0day-ci/archive/20231124/202311241915.3OrRNpQB-lkp@xxxxxxxxx/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce: (https://download.01.org/0day-ci/archive/20231124/202311241915.3OrRNpQB-lkp@xxxxxxxxx/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@xxxxxxxxx>
| Reported-by: Dan Carpenter <error27@xxxxxxxxx>
| Closes: https://lore.kernel.org/r/202311241915.3OrRNpQB-lkp@xxxxxxxxx/

smatch warnings:
fs/dcache.c:2062 __d_obtain_alias() warn: variable dereferenced before check 'inode' (see line 2059)

vim +/inode +2062 fs/dcache.c

f9c34674bc60e5 Miklos Szeredi    2018-01-19  2057  static struct dentry *__d_obtain_alias(struct inode *inode, bool disconnected)
f9c34674bc60e5 Miklos Szeredi    2018-01-19  2058  {
8a0af412cf8ba3 Al Viro           2023-11-18 @2059  	struct super_block *sb = inode->i_sb;
                                                                                 ^^^^^^^^^^^
Unchecked dereference

8a0af412cf8ba3 Al Viro           2023-11-18  2060  	struct dentry *new, *res;
f9c34674bc60e5 Miklos Szeredi    2018-01-19  2061  
f9c34674bc60e5 Miklos Szeredi    2018-01-19 @2062  	if (!inode)
                                                            ^^^^^^
NULL check is too late

f9c34674bc60e5 Miklos Szeredi    2018-01-19  2063  		return ERR_PTR(-ESTALE);
f9c34674bc60e5 Miklos Szeredi    2018-01-19  2064  	if (IS_ERR(inode))
f9c34674bc60e5 Miklos Szeredi    2018-01-19  2065  		return ERR_CAST(inode);
f9c34674bc60e5 Miklos Szeredi    2018-01-19  2066  
8a0af412cf8ba3 Al Viro           2023-11-18  2067  	res = d_find_any_alias(inode); /* existing alias? */
f9c34674bc60e5 Miklos Szeredi    2018-01-19  2068  	if (res)

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux