[tip:locking/futex 2/6] kernel/futex/core.c:1748:2-8: WARNING: NULL check before some freeing functions is not needed.

From: kernel test robot
Date: Thu Jul 17 2025 - 11:50:37 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git locking/futex
head: 7497e947bc1d3f761b46c2105c8ae37af98add54
commit: 56180dd20c19e5b0fa34822997a9ac66b517e7b3 [2/6] futex: Use RCU-based per-CPU reference counting instead of rcuref_t
config: microblaze-randconfig-r052-20250717 (https://download.01.org/0day-ci/archive/20250717/202507172340.xrO8KXQq-lkp@xxxxxxxxx/config)
compiler: microblaze-linux-gcc (GCC) 11.5.0

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/202507172340.xrO8KXQq-lkp@xxxxxxxxx/

cocci warnings: (new ones prefixed by >>)
>> kernel/futex/core.c:1748:2-8: WARNING: NULL check before some freeing functions is not needed.

vim +1748 kernel/futex/core.c

56180dd20c19e5 Peter Zijlstra 2025-07-10 1739
80367ad01d93ac Sebastian Andrzej Siewior 2025-04-16 1740 void futex_hash_free(struct mm_struct *mm)
80367ad01d93ac Sebastian Andrzej Siewior 2025-04-16 1741 {
bd54df5ea7cada Sebastian Andrzej Siewior 2025-04-16 1742 struct futex_private_hash *fph;
bd54df5ea7cada Sebastian Andrzej Siewior 2025-04-16 1743
56180dd20c19e5 Peter Zijlstra 2025-07-10 1744 free_percpu(mm->futex_ref);
bd54df5ea7cada Sebastian Andrzej Siewior 2025-04-16 1745 kvfree(mm->futex_phash_new);
bd54df5ea7cada Sebastian Andrzej Siewior 2025-04-16 1746 fph = rcu_dereference_raw(mm->futex_phash);
56180dd20c19e5 Peter Zijlstra 2025-07-10 1747 if (fph)
bd54df5ea7cada Sebastian Andrzej Siewior 2025-04-16 @1748 kvfree(fph);
bd54df5ea7cada Sebastian Andrzej Siewior 2025-04-16 1749 }
bd54df5ea7cada Sebastian Andrzej Siewior 2025-04-16 1750

:::::: The code at line 1748 was first introduced by commit
:::::: bd54df5ea7cadac520e346d5f0fe5d58e635b6ba futex: Allow to resize the private local hash

:::::: TO: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
:::::: CC: Peter Zijlstra <peterz@xxxxxxxxxxxxx>

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