btrfs: use kmemdup in btrfs_uring_encoded_read
PATCH 1/1 btrfs: use kmemdup in btrfs_uring_encoded_read
Use kmemdup in btrfs_uring_encoded_read rather than kmalloc followed by memcpy.
Signed-off-by Mark Harmstone <[email protected]>
Reported-by kernel test robot <[email protected]>
--- fs/btrfs/ioctl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
fs/btrfs/ioctl.c +2 -3
@@ -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);
Signature · 1 line
2.45.2
Looks good,
Reviewed-by Johannes Thumshirn <[email protected]>
Quoted 6 lines · Mark Harmstone
Use kmemdup in
btrfs_uring_encoded_readrather than kmalloc followed by memcpy.Signed-off-by Mark Harmstone <[email protected]>Reported-by kernel test robot <[email protected]>
Added to for-next, thanks.