Re: [linux-next:master 2720/3921] lib/alloc_tag.c:142 alloc_tag_init() warn: passing zero to 'PTR_ERR'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 5, 2024 at 6:51 AM Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:
>
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head:   8568bb2ccc278f344e6ac44af6ed010a90aa88dc
> commit: 9e2dcefa791e9d14006b360fba3455510fd3325d [2720/3921] lib: add allocation tagging support for memory allocation profiling
> config: microblaze-randconfig-r081-20240405 (https://download.01.org/0day-ci/archive/20240405/202404051340.7Wo7oiJ5-lkp@xxxxxxxxx/config)
> compiler: microblaze-linux-gcc (GCC) 13.2.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>
> | Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> | Closes: https://lore.kernel.org/r/202404051340.7Wo7oiJ5-lkp@xxxxxxxxx/
>
> smatch warnings:
> lib/alloc_tag.c:142 alloc_tag_init() warn: passing zero to 'PTR_ERR'
>
> vim +/PTR_ERR +142 lib/alloc_tag.c
>
> 9e2dcefa791e9d Suren Baghdasaryan 2024-03-21  132  static int __init alloc_tag_init(void)
> 9e2dcefa791e9d Suren Baghdasaryan 2024-03-21  133  {
> 9e2dcefa791e9d Suren Baghdasaryan 2024-03-21  134       const struct codetag_type_desc desc = {
> 9e2dcefa791e9d Suren Baghdasaryan 2024-03-21  135               .section        = "alloc_tags",
> 9e2dcefa791e9d Suren Baghdasaryan 2024-03-21  136               .tag_size       = sizeof(struct alloc_tag),
> 9e2dcefa791e9d Suren Baghdasaryan 2024-03-21  137               .module_unload  = alloc_tag_module_unload,
> 9e2dcefa791e9d Suren Baghdasaryan 2024-03-21  138       };
> 9e2dcefa791e9d Suren Baghdasaryan 2024-03-21  139
> 9e2dcefa791e9d Suren Baghdasaryan 2024-03-21  140       alloc_tag_cttype = codetag_register_type(&desc);
> 9e2dcefa791e9d Suren Baghdasaryan 2024-03-21  141       if (IS_ERR_OR_NULL(alloc_tag_cttype))
>                                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> This should just be IS_ERR().  I have written a blog that has more
> details:
>
> https://staticthinking.wordpress.com/2022/08/01/mixing-error-pointers-and-null/

Sorry for the delay, I somehow missed this report. You are absolutely
right about the fix. codetag_register_type() never returns NULL, so
IS_ERR() should be used here. I'll post a fix shortly.
Thanks,
Suren.

>
> 9e2dcefa791e9d Suren Baghdasaryan 2024-03-21 @142               return PTR_ERR(alloc_tag_cttype);
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
>





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux