[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1a12a05451a1fc9bc37e739a79a0ba667656ade4.1735267151.git.xiaopei01@kylinos.cn>
Date: Fri, 27 Dec 2024 10:53:02 +0800
From: Pei Xiao <xiaopei01@...inos.cn>
To: djwong@...nel.org,
linux-xfs@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Pei Xiao <xiaopei01@...inos.cn>,
kernel test robot <lkp@...el.com>
Subject: [PATCH] xfs: use kvmemdup() to replace kvmalloc + memcpy
Fix cocci warning:
fs/xfs/libxfs/xfs_attr_leaf.c:1061:13-20: WARNING opportunity for kmemdup
Fixes: de631e1a8b71 ("xfs: use kvmalloc for xattr buffers")
Reported-by: kernel test robot <lkp@...el.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202403210204.LPPBJMhf-lkp@intel.com/
Signed-off-by: Pei Xiao <xiaopei01@...inos.cn>
---
fs/xfs/libxfs/xfs_attr_leaf.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c
index fddb55605e0c..db45f22e89d0 100644
--- a/fs/xfs/libxfs/xfs_attr_leaf.c
+++ b/fs/xfs/libxfs/xfs_attr_leaf.c
@@ -1136,8 +1136,9 @@ xfs_attr3_leaf_to_shortform(
trace_xfs_attr_leaf_to_sf(args);
- tmpbuffer = kvmalloc(args->geo->blksize, GFP_KERNEL | __GFP_NOFAIL);
- memcpy(tmpbuffer, bp->b_addr, args->geo->blksize);
+ tmpbuffer = kvmemdup(bp->b_addr, args->geo->blksize, GFP_KERNEL | __GFP_NOFAIL);
+ if (!tmpbuffer)
+ return -ENOMEM;
leaf = (xfs_attr_leafblock_t *)tmpbuffer;
xfs_attr3_leaf_hdr_from_disk(args->geo, &ichdr, leaf);
--
2.25.1
Powered by blists - more mailing lists