All of lore.kernel.org
 help / color / mirror / Atom feed
* fs/xfs/libxfs/xfs_dir2.c:336:15-22: WARNING opportunity for kmemdup
@ 2024-03-23 15:08 kernel test robot
  2024-03-25  5:01 ` Darrick J. Wong
  0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2024-03-23 15:08 UTC (permalink / raw)
  To: Dave Chinner; +Cc: oe-kbuild-all, linux-kernel, Chandan Babu R, Darrick J. Wong

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   bfa8f18691ed2e978e4dd51190569c434f93e268
commit: f078d4ea827607867d42fb3b2ef907caf86ce49d xfs: convert kmem_alloc() to kmalloc()
date:   6 weeks ago
config: x86_64-randconfig-103-20240323 (https://download.01.org/0day-ci/archive/20240323/202403232305.aLpp8AlJ-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0

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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202403232305.aLpp8AlJ-lkp@intel.com/

cocci warnings: (new ones prefixed by >>)
>> fs/xfs/libxfs/xfs_dir2.c:336:15-22: WARNING opportunity for kmemdup

vim +336 fs/xfs/libxfs/xfs_dir2.c

   319	
   320	/*
   321	 * If doing a CI lookup and case-insensitive match, dup actual name into
   322	 * args.value. Return EEXIST for success (ie. name found) or an error.
   323	 */
   324	int
   325	xfs_dir_cilookup_result(
   326		struct xfs_da_args *args,
   327		const unsigned char *name,
   328		int		len)
   329	{
   330		if (args->cmpresult == XFS_CMP_DIFFERENT)
   331			return -ENOENT;
   332		if (args->cmpresult != XFS_CMP_CASE ||
   333						!(args->op_flags & XFS_DA_OP_CILOOKUP))
   334			return -EEXIST;
   335	
 > 336		args->value = kmalloc(len, GFP_NOFS | __GFP_RETRY_MAYFAIL);
   337		if (!args->value)
   338			return -ENOMEM;
   339	
   340		memcpy(args->value, name, len);
   341		args->valuelen = len;
   342		return -EEXIST;
   343	}
   344	

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: fs/xfs/libxfs/xfs_dir2.c:336:15-22: WARNING opportunity for kmemdup
  2024-03-23 15:08 fs/xfs/libxfs/xfs_dir2.c:336:15-22: WARNING opportunity for kmemdup kernel test robot
@ 2024-03-25  5:01 ` Darrick J. Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2024-03-25  5:01 UTC (permalink / raw)
  To: xfs
  Cc: kernel test robot, Dave Chinner, oe-kbuild-all, linux-kernel,
	Chandan Babu R

On Sat, Mar 23, 2024 at 11:08:59PM +0800, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   bfa8f18691ed2e978e4dd51190569c434f93e268
> commit: f078d4ea827607867d42fb3b2ef907caf86ce49d xfs: convert kmem_alloc() to kmalloc()
> date:   6 weeks ago
> config: x86_64-randconfig-103-20240323 (https://download.01.org/0day-ci/archive/20240323/202403232305.aLpp8AlJ-lkp@intel.com/config)
> compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
> 
> 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@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202403232305.aLpp8AlJ-lkp@intel.com/
> 
> cocci warnings: (new ones prefixed by >>)
> >> fs/xfs/libxfs/xfs_dir2.c:336:15-22: WARNING opportunity for kmemdup

It occurred to me that this message isn't about a stray kmemdup that
could cause a WARN() message to get logged or anything like that; it's a
notice that we could collapse lines 336 and 340 into:

	args->value = kmemdup(name, len, GFP_NOFS | __GFP_RETRY_MAYFAIL);

Anyone want to tackle that?

There's a second one you could tackle too:
https://lore.kernel.org/oe-kbuild-all/202403210204.LPPBJMhf-lkp@intel.com/T/#u

--D

> vim +336 fs/xfs/libxfs/xfs_dir2.c
> 
>    319	
>    320	/*
>    321	 * If doing a CI lookup and case-insensitive match, dup actual name into
>    322	 * args.value. Return EEXIST for success (ie. name found) or an error.
>    323	 */
>    324	int
>    325	xfs_dir_cilookup_result(
>    326		struct xfs_da_args *args,
>    327		const unsigned char *name,
>    328		int		len)
>    329	{
>    330		if (args->cmpresult == XFS_CMP_DIFFERENT)
>    331			return -ENOENT;
>    332		if (args->cmpresult != XFS_CMP_CASE ||
>    333						!(args->op_flags & XFS_DA_OP_CILOOKUP))
>    334			return -EEXIST;
>    335	
>  > 336		args->value = kmalloc(len, GFP_NOFS | __GFP_RETRY_MAYFAIL);
>    337		if (!args->value)
>    338			return -ENOMEM;
>    339	
>    340		memcpy(args->value, name, len);
>    341		args->valuelen = len;
>    342		return -EEXIST;
>    343	}
>    344	
> 
> -- 
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-25  5:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-23 15:08 fs/xfs/libxfs/xfs_dir2.c:336:15-22: WARNING opportunity for kmemdup kernel test robot
2024-03-25  5:01 ` Darrick J. Wong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.