fs/xfs/xfs_exchmaps_item.c:57:5-24: WARNING: atomic_dec_and_test variation before object free at line 58.
From: kernel test robot
Date: Wed Dec 25 2024 - 18:06:50 EST
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 9b2ffa6148b1e4468d08f7e0e7e371c43cac9ffe
commit: 6c08f434bd33f88cf169e9e43c7a5e42fb3f2118 xfs: introduce a file mapping exchange log intent item
date: 8 months ago
config: hexagon-randconfig-r064-20241225 (https://download.01.org/0day-ci/archive/20241226/202412260634.uSDUNyYS-lkp@xxxxxxxxx/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 9daf10ff8f29ba3a88a105aaa9d2379c21b77d35)
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>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412260634.uSDUNyYS-lkp@xxxxxxxxx/
cocci warnings: (new ones prefixed by >>)
>> fs/xfs/xfs_exchmaps_item.c:57:5-24: WARNING: atomic_dec_and_test variation before object free at line 58.
vim +57 fs/xfs/xfs_exchmaps_item.c
44
45 /*
46 * Freeing the XMI requires that we remove it from the AIL if it has already
47 * been placed there. However, the XMI may not yet have been placed in the AIL
48 * when called by xfs_xmi_release() from XMD processing due to the ordering of
49 * committed vs unpin operations in bulk insert operations. Hence the reference
50 * count to ensure only the last caller frees the XMI.
51 */
52 STATIC void
53 xfs_xmi_release(
54 struct xfs_xmi_log_item *xmi_lip)
55 {
56 ASSERT(atomic_read(&xmi_lip->xmi_refcount) > 0);
> 57 if (atomic_dec_and_test(&xmi_lip->xmi_refcount)) {
> 58 xfs_trans_ail_delete(&xmi_lip->xmi_item, 0);
59 xfs_xmi_item_free(xmi_lip);
60 }
61 }
62
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki