include/linux/ioremap.h:21 is_ioremap_addr() warn: always true condition '(addr >= (0)) => (0-u32max >= 0)'

From: kernel test robot
Date: Thu Oct 31 2024 - 06:55:21 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 0fc810ae3ae110f9e2fcccce80fc8c8d62f97907
commit: ac88ff6b9d7dea9f0907c86bdae204dde7d5c0e6 riscv: fix VMALLOC_START definition
date: 11 months ago
config: riscv-randconfig-r071-20241030 (https://download.01.org/0day-ci/archive/20241031/202410311824.fJAhvOUy-lkp@xxxxxxxxx/config)
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)

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/202410311824.fJAhvOUy-lkp@xxxxxxxxx/

smatch warnings:
include/linux/ioremap.h:21 is_ioremap_addr() warn: always true condition '(addr >= (0)) => (0-u32max >= 0)'

vim +21 include/linux/ioremap.h

016fec91013cfb Baoquan He 2023-07-06 7
016fec91013cfb Baoquan He 2023-07-06 8 #if defined(CONFIG_HAS_IOMEM) || defined(CONFIG_GENERIC_IOREMAP)
016fec91013cfb Baoquan He 2023-07-06 9 /*
016fec91013cfb Baoquan He 2023-07-06 10 * Ioremap often, but not always uses the generic vmalloc area. E.g on
016fec91013cfb Baoquan He 2023-07-06 11 * Power ARCH, it could have different ioremap space.
016fec91013cfb Baoquan He 2023-07-06 12 */
016fec91013cfb Baoquan He 2023-07-06 13 #ifndef IOREMAP_START
016fec91013cfb Baoquan He 2023-07-06 14 #define IOREMAP_START VMALLOC_START
016fec91013cfb Baoquan He 2023-07-06 15 #define IOREMAP_END VMALLOC_END
016fec91013cfb Baoquan He 2023-07-06 16 #endif
016fec91013cfb Baoquan He 2023-07-06 17 static inline bool is_ioremap_addr(const void *x)
016fec91013cfb Baoquan He 2023-07-06 18 {
016fec91013cfb Baoquan He 2023-07-06 19 unsigned long addr = (unsigned long)kasan_reset_tag(x);
016fec91013cfb Baoquan He 2023-07-06 20
016fec91013cfb Baoquan He 2023-07-06 @21 return addr >= IOREMAP_START && addr < IOREMAP_END;
016fec91013cfb Baoquan He 2023-07-06 22 }
016fec91013cfb Baoquan He 2023-07-06 23 #else
016fec91013cfb Baoquan He 2023-07-06 24 static inline bool is_ioremap_addr(const void *x)
016fec91013cfb Baoquan He 2023-07-06 25 {
016fec91013cfb Baoquan He 2023-07-06 26 return false;
016fec91013cfb Baoquan He 2023-07-06 27 }
016fec91013cfb Baoquan He 2023-07-06 28 #endif
016fec91013cfb Baoquan He 2023-07-06 29

:::::: The code at line 21 was first introduced by commit
:::::: 016fec91013cfb27c9f5a101a87ae8266537fed1 mm: move is_ioremap_addr() into new header file

:::::: TO: Baoquan He <bhe@xxxxxxxxxx>
:::::: CC: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>

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