Re: [PATCH] mm/kfence: fix a potential NULL pointer dereference

From: kernel test robot
Date: Wed Apr 27 2022 - 07:38:32 EST


Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on hnaz-mm/master]

url: https://github.com/intel-lab-lkp/linux/commits/cgel-zte-gmail-com/mm-kfence-fix-a-potential-NULL-pointer-dereference/20220427-151258
base: https://github.com/hnaz/linux-mm master
config: arm-buildonly-randconfig-r004-20220427 (https://download.01.org/0day-ci/archive/20220427/202204271916.aTcNyVdc-lkp@xxxxxxxxx/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 1cddcfdc3c683b393df1a5c9063252eb60e52818)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/intel-lab-lkp/linux/commit/920e9e639493bc72bee803c763f09760e3acd063
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review cgel-zte-gmail-com/mm-kfence-fix-a-potential-NULL-pointer-dereference/20220427-151258
git checkout 920e9e639493bc72bee803c763f09760e3acd063
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash mm/kfence/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

mm/kfence/core.c:1067:23: error: use of undeclared identifier 'addr'
kfence_guarded_free(addr, meta, false);
^
>> mm/kfence/core.c:1075:23: warning: incompatible pointer to integer conversion passing 'void *' to parameter of type 'unsigned long' [-Wint-conversion]
kfence_report_error(addr, false, NULL, NULL, KFENCE_ERROR_INVALID);
^~~~
mm/kfence/kfence.h:129:40: note: passing argument to parameter 'address' here
void kfence_report_error(unsigned long address, bool is_write, struct pt_regs *regs,
^
1 warning and 1 error generated.


vim +1075 mm/kfence/core.c

1069
1070 void __kfence_free(void *addr)
1071 {
1072 struct kfence_metadata *meta = addr_to_metadata((unsigned long)addr);
1073
1074 if (!meta) {
> 1075 kfence_report_error(addr, false, NULL, NULL, KFENCE_ERROR_INVALID);
1076 return;
1077 }
1078
1079 __try_free_kfence_meta(meta);
1080 }
1081

--
0-DAY CI Kernel Test Service
https://01.org/lkp