diff mbox series

btrfs: use kmemdup in btrfs_uring_encoded_read

Message ID 20241111190619.164853-1-maharmstone@fb.com (mailing list archive)
State New
Headers show
Series btrfs: use kmemdup in btrfs_uring_encoded_read | expand

Commit Message

Mark Harmstone Nov. 11, 2024, 7:06 p.m. UTC
Use kmemdup in btrfs_uring_encoded_read rather than kmalloc followed by
memcpy.

Signed-off-by: Mark Harmstone <maharmstone@fb.com>
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202411050846.GI8oh5IK-lkp@intel.com/
---
 fs/btrfs/ioctl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Johannes Thumshirn Nov. 12, 2024, 7:11 a.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
diff mbox series

Patch

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 9ff1aea7910c..fb1a21533825 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -4983,15 +4983,14 @@  static int btrfs_uring_encoded_read(struct io_uring_cmd *cmd, unsigned int issue
 		 * undo this.
 		 */
 		if (!iov) {
-			iov = kmalloc(sizeof(struct iovec) * args.iovcnt, GFP_NOFS);
+			iov = kmemdup(iovstack, sizeof(struct iovec) * args.iovcnt,
+				      GFP_NOFS);
 			if (!iov) {
 				unlock_extent(io_tree, start, lockend, &cached_state);
 				btrfs_inode_unlock(inode, BTRFS_ILOCK_SHARED);
 				ret = -ENOMEM;
 				goto out_acct;
 			}
-
-			memcpy(iov, iovstack, sizeof(struct iovec) * args.iovcnt);
 		}
 
 		count = min_t(u64, iov_iter_count(&iter), disk_io_size);