Skip to content

Commit

Permalink
CIFS: Use memdup_user() rather than duplicating its implementation
Browse files Browse the repository at this point in the history
Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.

Generated by: scripts/coccinelle/api/memdup_user.cocci

Fixes: f5b05d6 ("cifs: add IOCTL for QUERY_INFO passthrough to userspace")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Markus Elfring authored and Steve French committed Nov 25, 2019
1 parent acd4680 commit cfaa118
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions fs/cifs/smb2ops.c
Original file line number Diff line number Diff line change
@@ -1402,15 +1402,10 @@ smb2_ioctl_query_info(const unsigned int xid,
if (smb3_encryption_required(tcon))
flags |= CIFS_TRANSFORM_REQ;

buffer = kmalloc(qi.output_buffer_length, GFP_KERNEL);
if (buffer == NULL)
return -ENOMEM;

if (copy_from_user(buffer, arg + sizeof(struct smb_query_info),
qi.output_buffer_length)) {
rc = -EFAULT;
goto iqinf_exit;
}
buffer = memdup_user(arg + sizeof(struct smb_query_info),
qi.output_buffer_length);
if (IS_ERR(buffer))
return PTR_ERR(buffer);

/* Open */
memset(&open_iov, 0, sizeof(open_iov));

0 comments on commit cfaa118

Please sign in to comment.