drivers/char/xillybus/xillybus_class.c:230 xillybus_find_inode() warn: variable dereferenced before check 'inode' (see line 226)

Dan Carpenter <[email protected]>
Newsgroups dev.linux.lists.oe-kbuild
Message-ID <20260807165502.6tU5aVmniAs_M85lp30i5qa4a4ZcgGoLQZRNBLeDT-o@z>
tree:   https://github.com/intel-lab-lkp/linux/commits/Eli-Billauer/char-xillybus-Improve-control-of-execution-flow-with-mutexes/20260806-033404
head:   d05c024c9354aabd2ea64be46e6fccbf24ba33cd
commit: 16edb90c39a5645b3803be32b2b77476efae2402 char: xillybus: Add defensive sanity checks
config: i386-randconfig-141 (https://download.01.org/0day-ci/archive/20260807/[email protected]/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
smatch: v0.5.0-9187-g5189e3fb

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 <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
drivers/char/xillybus/xillybus_class.c:230 xillybus_find_inode() warn: variable dereferenced before check 'inode' (see line 226)

vim +/inode +230 drivers/char/xillybus/xillybus_class.c

8cb5d216ab3365 Eli Billauer  2021-05-26  223  int xillybus_find_inode(struct inode *inode,
8cb5d216ab3365 Eli Billauer  2021-05-26  224  			void **private_data, int *index)
8cb5d216ab3365 Eli Billauer  2021-05-26  225  {
8cb5d216ab3365 Eli Billauer  2021-05-26 @226  	int minor = iminor(inode);
8cb5d216ab3365 Eli Billauer  2021-05-26  227  	int major = imajor(inode);
                                                                   ^^^^^
Unchecked dereferences

4834f9898c7301 Jakob Koschel 2022-03-24  228  	struct xilly_unit *unit = NULL, *iter;
8cb5d216ab3365 Eli Billauer  2021-05-26  229  
16edb90c39a564 Eli Billauer  2026-06-30 @230  	if (!inode || !private_data || !index)
                                                    ^^^^^^
Checked too late.

16edb90c39a564 Eli Billauer  2026-06-30  231  		return -ENODEV;
16edb90c39a564 Eli Billauer  2026-06-30  232  
8cb5d216ab3365 Eli Billauer  2021-05-26  233  	mutex_lock(&unit_mutex);
8cb5d216ab3365 Eli Billauer  2021-05-26  234  
4834f9898c7301 Jakob Koschel 2022-03-24  235  	list_for_each_entry(iter, &unit_list, list_entry)

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.