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

kernel test robot
2022-04-27T08:51:49Z

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: parisc-allyesconfig (https://download.01.org/0day-ci/archive/20220427/202204271645.QTJoeela-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 11.3.0
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
# 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=gcc-11.3.0 make.cross W=1 O=build_dir ARCH=parisc SHELL=/bin/bash mm/

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

All warnings (new ones prefixed by >>):

mm/kfence/core.c: In function '__try_free_kfence_meta':
mm/kfence/core.c:1067:37: error: 'addr' undeclared (first use in this function)
1067 | kfence_guarded_free(addr, meta, false);
| ^~~~
mm/kfence/core.c:1067:37: note: each undeclared identifier is reported only once for each function it appears in
mm/kfence/core.c: In function '__kfence_free':
>> mm/kfence/core.c:1075:37: warning: passing argument 1 of 'kfence_report_error' makes integer from pointer without a cast [-Wint-conversion]
1075 | kfence_report_error(addr, false, NULL, NULL, KFENCE_ERROR_INVALID);
| ^~~~
| |
| void *
In file included from mm/kfence/core.c:37:
mm/kfence/kfence.h:129:40: note: expected 'long unsigned int' but argument is of type 'void *'
129 | void kfence_report_error(unsigned long address, bool is_write, struct pt_regs *regs,
| ~~~~~~~~~~~~~~^~~~~~~

vim +/kfence_report_error +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