* [linux-next:master 10746/11779] fs/xfs/xfs_mru_cache.c:451 xfs_mru_cache_insert() error: we previously assumed 'mru' could be null (see line 429)
@ 2025-05-23 9:58 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2025-05-21 11:24 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: Christoph Hellwig <hch@lst.de>
CC: Carlos Maiolino <cem@kernel.org>
CC: Hans Holmberg <hans.holmberg@wdc.com>
CC: "Darrick J. Wong" <djwong@kernel.org>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: 8566fc3b96539e3235909d6bdda198e1282beaed
commit: 70b95cb86513d7f6d084ddc8e961a1cab9022e14 [10746/11779] xfs: free the item in xfs_mru_cache_insert on failure
:::::: branch date: 5 days ago
:::::: commit date: 7 days ago
config: i386-randconfig-141-20250521 (https://download.01.org/0day-ci/archive/20250521/202505211940.jjLX0rQI-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
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/202505211940.jjLX0rQI-lkp@intel.com/
New smatch warnings:
fs/xfs/xfs_mru_cache.c:451 xfs_mru_cache_insert() error: we previously assumed 'mru' could be null (see line 429)
Old smatch warnings:
fs/xfs/xfs_mru_cache.c:272 _xfs_mru_cache_reap() warn: can 'mru' even be NULL?
vim +/mru +451 fs/xfs/xfs_mru_cache.c
2a82b8be8a8dac David Chinner 2007-07-11 412
2a82b8be8a8dac David Chinner 2007-07-11 413 /*
2a82b8be8a8dac David Chinner 2007-07-11 414 * To insert an element, call xfs_mru_cache_insert() with the data store, the
2a82b8be8a8dac David Chinner 2007-07-11 415 * element's key and the client data pointer. This function returns 0 on
2a82b8be8a8dac David Chinner 2007-07-11 416 * success or ENOMEM if memory for the data element couldn't be allocated.
70b95cb86513d7 Christoph Hellwig 2025-05-14 417 *
70b95cb86513d7 Christoph Hellwig 2025-05-14 418 * The passed in elem is freed through the per-cache free_func on failure.
2a82b8be8a8dac David Chinner 2007-07-11 419 */
2a82b8be8a8dac David Chinner 2007-07-11 420 int
2a82b8be8a8dac David Chinner 2007-07-11 421 xfs_mru_cache_insert(
22328d712dd7fd Christoph Hellwig 2014-04-23 422 struct xfs_mru_cache *mru,
2a82b8be8a8dac David Chinner 2007-07-11 423 unsigned long key,
22328d712dd7fd Christoph Hellwig 2014-04-23 424 struct xfs_mru_cache_elem *elem)
2a82b8be8a8dac David Chinner 2007-07-11 425 {
70b95cb86513d7 Christoph Hellwig 2025-05-14 426 int error = -EINVAL;
2a82b8be8a8dac David Chinner 2007-07-11 427
2a82b8be8a8dac David Chinner 2007-07-11 428 ASSERT(mru && mru->lists);
2a82b8be8a8dac David Chinner 2007-07-11 @429 if (!mru || !mru->lists)
70b95cb86513d7 Christoph Hellwig 2025-05-14 430 goto out_free;
2a82b8be8a8dac David Chinner 2007-07-11 431
70b95cb86513d7 Christoph Hellwig 2025-05-14 432 error = -ENOMEM;
0b3a76e955ebe3 Dave Chinner 2024-01-16 433 if (radix_tree_preload(GFP_KERNEL))
70b95cb86513d7 Christoph Hellwig 2025-05-14 434 goto out_free;
2a82b8be8a8dac David Chinner 2007-07-11 435
2a82b8be8a8dac David Chinner 2007-07-11 436 INIT_LIST_HEAD(&elem->list_node);
2a82b8be8a8dac David Chinner 2007-07-11 437 elem->key = key;
2a82b8be8a8dac David Chinner 2007-07-11 438
ba74d0cba51dca Eric Sandeen 2007-10-11 439 spin_lock(&mru->lock);
2451337dd04390 Dave Chinner 2014-06-25 440 error = radix_tree_insert(&mru->store, key, elem);
2a82b8be8a8dac David Chinner 2007-07-11 441 radix_tree_preload_end();
22328d712dd7fd Christoph Hellwig 2014-04-23 442 if (!error)
2a82b8be8a8dac David Chinner 2007-07-11 443 _xfs_mru_cache_list_insert(mru, elem);
ba74d0cba51dca Eric Sandeen 2007-10-11 444 spin_unlock(&mru->lock);
2a82b8be8a8dac David Chinner 2007-07-11 445
70b95cb86513d7 Christoph Hellwig 2025-05-14 446 if (error)
70b95cb86513d7 Christoph Hellwig 2025-05-14 447 goto out_free;
70b95cb86513d7 Christoph Hellwig 2025-05-14 448 return 0;
70b95cb86513d7 Christoph Hellwig 2025-05-14 449
70b95cb86513d7 Christoph Hellwig 2025-05-14 450 out_free:
70b95cb86513d7 Christoph Hellwig 2025-05-14 @451 mru->free_func(mru->data, elem);
ce695c6551f948 Christoph Hellwig 2014-04-23 452 return error;
2a82b8be8a8dac David Chinner 2007-07-11 453 }
2a82b8be8a8dac David Chinner 2007-07-11 454
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* [linux-next:master 10746/11779] fs/xfs/xfs_mru_cache.c:451 xfs_mru_cache_insert() error: we previously assumed 'mru' could be null (see line 429)
@ 2025-05-23 9:58 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-05-23 9:58 UTC (permalink / raw)
To: oe-kbuild, Christoph Hellwig
Cc: lkp, oe-kbuild-all, Carlos Maiolino, Hans Holmberg,
Darrick J. Wong
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: 8566fc3b96539e3235909d6bdda198e1282beaed
commit: 70b95cb86513d7f6d084ddc8e961a1cab9022e14 [10746/11779] xfs: free the item in xfs_mru_cache_insert on failure
config: i386-randconfig-141-20250521 (https://download.01.org/0day-ci/archive/20250521/202505211940.jjLX0rQI-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
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 <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202505211940.jjLX0rQI-lkp@intel.com/
New smatch warnings:
fs/xfs/xfs_mru_cache.c:451 xfs_mru_cache_insert() error: we previously assumed 'mru' could be null (see line 429)
vim +/mru +451 fs/xfs/xfs_mru_cache.c
2a82b8be8a8dac David Chinner 2007-07-11 420 int
2a82b8be8a8dac David Chinner 2007-07-11 421 xfs_mru_cache_insert(
22328d712dd7fd Christoph Hellwig 2014-04-23 422 struct xfs_mru_cache *mru,
2a82b8be8a8dac David Chinner 2007-07-11 423 unsigned long key,
22328d712dd7fd Christoph Hellwig 2014-04-23 424 struct xfs_mru_cache_elem *elem)
2a82b8be8a8dac David Chinner 2007-07-11 425 {
70b95cb86513d7 Christoph Hellwig 2025-05-14 426 int error = -EINVAL;
2a82b8be8a8dac David Chinner 2007-07-11 427
2a82b8be8a8dac David Chinner 2007-07-11 428 ASSERT(mru && mru->lists);
2a82b8be8a8dac David Chinner 2007-07-11 @429 if (!mru || !mru->lists)
mru can't be NULL but if it were
70b95cb86513d7 Christoph Hellwig 2025-05-14 430 goto out_free;
2a82b8be8a8dac David Chinner 2007-07-11 431
70b95cb86513d7 Christoph Hellwig 2025-05-14 432 error = -ENOMEM;
0b3a76e955ebe3 Dave Chinner 2024-01-16 433 if (radix_tree_preload(GFP_KERNEL))
70b95cb86513d7 Christoph Hellwig 2025-05-14 434 goto out_free;
2a82b8be8a8dac David Chinner 2007-07-11 435
2a82b8be8a8dac David Chinner 2007-07-11 436 INIT_LIST_HEAD(&elem->list_node);
2a82b8be8a8dac David Chinner 2007-07-11 437 elem->key = key;
2a82b8be8a8dac David Chinner 2007-07-11 438
ba74d0cba51dca Eric Sandeen 2007-10-11 439 spin_lock(&mru->lock);
2451337dd04390 Dave Chinner 2014-06-25 440 error = radix_tree_insert(&mru->store, key, elem);
2a82b8be8a8dac David Chinner 2007-07-11 441 radix_tree_preload_end();
22328d712dd7fd Christoph Hellwig 2014-04-23 442 if (!error)
2a82b8be8a8dac David Chinner 2007-07-11 443 _xfs_mru_cache_list_insert(mru, elem);
ba74d0cba51dca Eric Sandeen 2007-10-11 444 spin_unlock(&mru->lock);
2a82b8be8a8dac David Chinner 2007-07-11 445
70b95cb86513d7 Christoph Hellwig 2025-05-14 446 if (error)
70b95cb86513d7 Christoph Hellwig 2025-05-14 447 goto out_free;
70b95cb86513d7 Christoph Hellwig 2025-05-14 448 return 0;
70b95cb86513d7 Christoph Hellwig 2025-05-14 449
70b95cb86513d7 Christoph Hellwig 2025-05-14 450 out_free:
70b95cb86513d7 Christoph Hellwig 2025-05-14 @451 mru->free_func(mru->data, elem);
then we are toast.
ce695c6551f948 Christoph Hellwig 2014-04-23 452 return error;
2a82b8be8a8dac David Chinner 2007-07-11 453 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [linux-next:master 10746/11779] fs/xfs/xfs_mru_cache.c:451 xfs_mru_cache_insert() error: we previously assumed 'mru' could be null (see line 429)
2025-05-23 9:58 ` Dan Carpenter
(?)
@ 2025-05-23 10:06 ` Christoph Hellwig
-1 siblings, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2025-05-23 10:06 UTC (permalink / raw)
To: Dan Carpenter
Cc: oe-kbuild, Christoph Hellwig, lkp, oe-kbuild-all, Carlos Maiolino,
Hans Holmberg, Darrick J. Wong
On Fri, May 23, 2025 at 12:58:57PM +0300, Dan Carpenter wrote:
> 2a82b8be8a8dac David Chinner 2007-07-11 428 ASSERT(mru && mru->lists);
> 2a82b8be8a8dac David Chinner 2007-07-11 @429 if (!mru || !mru->lists)
>
> mru can't be NULL but if it were
>
> 70b95cb86513d7 Christoph Hellwig 2025-05-14 450 out_free:
> 70b95cb86513d7 Christoph Hellwig 2025-05-14 @451 mru->free_func(mru->data, elem);
>
> then we are toast.
Yeah. Fortunately it is just a debug check for an invalid API.
I'd be tempted to just remove the check and only leave in the assert
for the same condition right above.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-23 10:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-21 11:24 [linux-next:master 10746/11779] fs/xfs/xfs_mru_cache.c:451 xfs_mru_cache_insert() error: we previously assumed 'mru' could be null (see line 429) kernel test robot
2025-05-23 9:58 ` Dan Carpenter
2025-05-23 10:06 ` Christoph Hellwig
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.