Re: [PATCH] net: sched: em_text: fix possible memory leak in em_text_destroy()

From: kernel test robot
Date: Wed Dec 20 2023 - 10:14:59 EST


Hi Hangyu,

kernel test robot noticed the following build warnings:

[auto build test WARNING on net-next/main]
[also build test WARNING on net/main linus/master v6.7-rc6]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Hangyu-Hua/net-sched-em_text-fix-possible-memory-leak-in-em_text_destroy/20231220-111317
base: net-next/main
patch link: https://lore.kernel.org/r/20231220030838.11751-1-hbh25y%40gmail.com
patch subject: [PATCH] net: sched: em_text: fix possible memory leak in em_text_destroy()
config: m68k-allmodconfig (https://download.01.org/0day-ci/archive/20231220/202312202228.58nFn5h0-lkp@xxxxxxxxx/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231220/202312202228.58nFn5h0-lkp@xxxxxxxxx/reproduce)

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/202312202228.58nFn5h0-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

net/sched/em_text.c: In function 'em_text_destroy':
>> net/sched/em_text.c:102:24: warning: passing argument 1 of 'kfree' makes pointer from integer without a cast [-Wint-conversion]
102 | kfree(m->data);
| ~^~~~~~
| |
| long unsigned int
In file included from net/sched/em_text.c:8:
include/linux/slab.h:227:24: note: expected 'const void *' but argument is of type 'long unsigned int'
227 | void kfree(const void *objp);
| ~~~~~~~~~~~~^~~~


vim +/kfree +102 net/sched/em_text.c

97
98 static void em_text_destroy(struct tcf_ematch *m)
99 {
100 if (EM_TEXT_PRIV(m) && EM_TEXT_PRIV(m)->config) {
101 textsearch_destroy(EM_TEXT_PRIV(m)->config);
> 102 kfree(m->data);
103 }
104 }
105

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