[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <df3d1da0-a907-80f3-b8f1-6ec7615086d9@web.de>
Date: Tue, 5 Nov 2019 22:42:13 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: linux-cifs@...r.kernel.org, Ronnie Sahlberg <lsahlber@...hat.com>,
Ronnie Sahlberg <lsahlber@...hat.com>
Cc: LKML <linux-kernel@...r.kernel.org>,
kernel-janitors@...r.kernel.org, Aurelien Aptel <aaptel@...e.com>
Subject: [PATCH 1/2] CIFS: Use memdup_user() rather than duplicating its
implementation
From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Tue, 5 Nov 2019 21:30:25 +0100
Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.
Generated by: scripts/coccinelle/api/memdup_user.cocci
Fixes: f5b05d622a3e99e6a97a189fe500414be802a05c ("cifs: add IOCTL for QUERY_INFO passthrough to userspace")
Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
fs/cifs/smb2ops.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
index 9cbb0ae0e53e..fde2e6d241a8 100644
--- a/fs/cifs/smb2ops.c
+++ b/fs/cifs/smb2ops.c
@@ -1413,15 +1413,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));
--
2.24.0
Powered by blists - more mailing lists