Re: [PATCH 2/3] kunit: add ability to register a simple cleanup function

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

 



Hi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on wireless-next/main]
[also build test WARNING on wireless/main linus/master v6.3-rc6 next-20230411]
[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/benjamin-sipsolutions-net/kunit-add-ability-to-register-a-simple-cleanup-function/20230330-012515
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/20230329172311.71861-2-benjamin%40sipsolutions.net
patch subject: [PATCH 2/3] kunit: add ability to register a simple cleanup function
config: arc-randconfig-m031-20230410 (https://download.01.org/0day-ci/archive/20230411/202304112307.LAyTVYon-lkp@xxxxxxxxx/config)
compiler: arc-elf-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Link: https://lore.kernel.org/oe-kbuild-all/202304112307.LAyTVYon-lkp@xxxxxxxxx/

New smatch warnings:
lib/kunit/test.c:750 kunit_add_cleanup() error: potential null dereference 'res'.  (kzalloc returns null)
lib/kunit/test.c:750 kunit_add_cleanup() error: we previously assumed 'res' could be null (see line 745)

Old smatch warnings:
lib/kunit/test.c:293 kunit_abort() warn: ignoring unreachable code.

vim +/res +750 lib/kunit/test.c

   735	
   736	void kunit_add_cleanup(struct kunit *test, kunit_cleanup_t cleanup_func,
   737			       const void *data, gfp_t internal_gfp)
   738	{
   739		struct kunit_auto_cleanup *res;
   740	
   741		KUNIT_ASSERT_NOT_NULL_MSG(test, cleanup_func,
   742					  "Cleanup function must not be NULL");
   743	
   744		res = kzalloc(sizeof(*res), internal_gfp);
 > 745		if (!res) {
   746			cleanup_func(data);
   747			KUNIT_ASSERT_FAILURE(test, "Could not allocate resource for cleanup");
   748		}
   749	
 > 750		res->cleanup_func = cleanup_func;
   751		res->resource.should_kfree = true;
   752	
   753		/* Cannot fail as init is NULL */
   754		__kunit_add_resource(test, NULL, kunit_auto_cleanup_free,
   755				     &res->resource, (void *)data);
   756	}
   757	EXPORT_SYMBOL_GPL(kunit_add_cleanup);
   758	

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



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux