Re: fs/hfsplus/unicode_test.c:43:2-7: WARNING: NULL check before some freeing functions is not needed.

From: Geert Uytterhoeven
Date: Mon Jan 05 2026 - 05:20:33 EST


On Fri, 2 Jan 2026 at 16:18, kernel test robot <lkp@xxxxxxxxx> wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: b69053dd3ffbc0d2dedbbc86182cdef6f641fe1b
> commit: 6f84ceb98538523f49d544aa7c671c87cc23d1b1 hfsplus: introduce KUnit tests for HFS+ string operations
> date: 6 weeks ago
> config: arm-randconfig-r051-20251231 (https://download.01.org/0day-ci/archive/20260102/202601022306.Dll2Dylo-lkp@xxxxxxxxx/config)
> compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 86b9f90b9574b3a7d15d28a91f6316459dcfa046)
>
> 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/202601022306.Dll2Dylo-lkp@xxxxxxxxx/
>
> cocci warnings: (new ones prefixed by >>)
> >> fs/hfsplus/unicode_test.c:43:2-7: WARNING: NULL check before some freeing functions is not needed.
>
> vim +43 fs/hfsplus/unicode_test.c
>
> 39
> 40 static void free_mock_str_env(struct test_mock_string_env *env)
> 41 {
> 42 if (env->buf)

Perhaps the intention was to check the env pointer instead?
Note that it is (currently) always a valid pointer.

> > 43 kfree(env->buf);
> 44 kfree(env);
> 45 }
> 46

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds