All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: drivers/char/xillybus/xillybus_class.c:230 xillybus_find_inode() warn: variable dereferenced before check 'inode' (see line 226)
Date: Fri, 07 Aug 2026 22:39:57 +0800	[thread overview]
Message-ID: <202608072246.Ee6OOcT6-lkp@intel.com> (raw)

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: Eli Billauer <eli.billauer@gmail.com>
CC: 0day robot <lkp@intel.com>

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
date:   2 days ago
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: i386-randconfig-141 (https://download.01.org/0day-ci/archive/20260807/202608072246.Ee6OOcT6-lkp@intel.com/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 <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202608072246.Ee6OOcT6-lkp@intel.com/

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  222  
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);
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)
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)
4834f9898c7301 Jakob Koschel 2022-03-24  236  		if (iter->major == major &&
4834f9898c7301 Jakob Koschel 2022-03-24  237  		    minor >= iter->lowest_minor &&
4834f9898c7301 Jakob Koschel 2022-03-24  238  		    minor < (iter->lowest_minor + iter->num_nodes)) {
4834f9898c7301 Jakob Koschel 2022-03-24  239  			unit = iter;
8cb5d216ab3365 Eli Billauer  2021-05-26  240  			break;
8cb5d216ab3365 Eli Billauer  2021-05-26  241  		}
8cb5d216ab3365 Eli Billauer  2021-05-26  242  
c002f04c0bc79e Eli Billauer  2022-11-17  243  	if (!unit) {
8cb5d216ab3365 Eli Billauer  2021-05-26  244  		mutex_unlock(&unit_mutex);
8cb5d216ab3365 Eli Billauer  2021-05-26  245  		return -ENODEV;
c002f04c0bc79e Eli Billauer  2022-11-17  246  	}
8cb5d216ab3365 Eli Billauer  2021-05-26  247  
8cb5d216ab3365 Eli Billauer  2021-05-26  248  	*private_data = unit->private_data;
8cb5d216ab3365 Eli Billauer  2021-05-26  249  	*index = minor - unit->lowest_minor;
8cb5d216ab3365 Eli Billauer  2021-05-26  250  
c002f04c0bc79e Eli Billauer  2022-11-17  251  	mutex_unlock(&unit_mutex);
8cb5d216ab3365 Eli Billauer  2021-05-26  252  	return 0;
8cb5d216ab3365 Eli Billauer  2021-05-26  253  }
8cb5d216ab3365 Eli Billauer  2021-05-26  254  EXPORT_SYMBOL(xillybus_find_inode);
8cb5d216ab3365 Eli Billauer  2021-05-26  255  

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

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <error27@gmail.com>
To: oe-kbuild@lists.linux.dev, Eli Billauer <eli.billauer@gmail.com>
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev
Subject: drivers/char/xillybus/xillybus_class.c:230 xillybus_find_inode() warn: variable dereferenced before check 'inode' (see line 226)
Date: Fri, 7 Aug 2026 19:55:02 +0300	[thread overview]
Message-ID: <202608072246.Ee6OOcT6-lkp@intel.com> (raw)
Message-ID: <20260807165502.6tU5aVmniAs_M85lp30i5qa4a4ZcgGoLQZRNBLeDT-o@z> (raw)

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/202608072246.Ee6OOcT6-lkp@intel.com/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 <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202608072246.Ee6OOcT6-lkp@intel.com/

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


             reply	other threads:[~2026-08-07 14:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-07 14:39 kernel test robot [this message]
2026-08-07 16:55 ` drivers/char/xillybus/xillybus_class.c:230 xillybus_find_inode() warn: variable dereferenced before check 'inode' (see line 226) Dan Carpenter
2026-08-08  7:35 ` Eli Billauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202608072246.Ee6OOcT6-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=error27@gmail.com \
    --cc=oe-kbuild@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.