linux-efi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] efi/efi_test: use memdup_user
@ 2017-04-29  1:42 Geliang Tang
       [not found] ` <d0d524b81d55b4e5f1708d5441e655c75365c0b8.1493383416.git.geliangtang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  2017-05-05 20:53 ` [PATCH 1/2] efi/efi_test: use memdup_user Matt Fleming
  0 siblings, 2 replies; 7+ messages in thread
From: Geliang Tang @ 2017-04-29  1:42 UTC (permalink / raw)
  To: Ivan Hu, Matt Fleming, Ard Biesheuvel
  Cc: Geliang Tang, linux-efi-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/firmware/efi/test/efi_test.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c
index 8cd578f..08129b7 100644
--- a/drivers/firmware/efi/test/efi_test.c
+++ b/drivers/firmware/efi/test/efi_test.c
@@ -71,18 +71,13 @@ copy_ucs2_from_user_len(efi_char16_t **dst, efi_char16_t __user *src,
 	if (!access_ok(VERIFY_READ, src, 1))
 		return -EFAULT;
 
-	buf = kmalloc(len, GFP_KERNEL);
-	if (!buf) {
+	buf = memdup_user(src, len);
+	if (IS_ERR(buf)) {
 		*dst = NULL;
-		return -ENOMEM;
+		return PTR_ERR(buf);
 	}
 	*dst = buf;
 
-	if (copy_from_user(*dst, src, len)) {
-		kfree(buf);
-		return -EFAULT;
-	}
-
 	return 0;
 }
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-05-10 10:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-29  1:42 [PATCH 1/2] efi/efi_test: use memdup_user Geliang Tang
     [not found] ` <d0d524b81d55b4e5f1708d5441e655c75365c0b8.1493383416.git.geliangtang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-04-29  1:42   ` [PATCH 2/2] efi/efi_test: drop useless kfree Geliang Tang
     [not found]     ` <427b03b5f10b41014818b9e78f79da9581b213df.1493383416.git.geliangtang-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-05-02  7:11       ` ivanhu
     [not found]         ` <a8b99581-70e3-bf9a-bf62-4b13a8cc292c-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2017-05-02 14:48           ` Geliang Tang
2017-05-05 20:53 ` [PATCH 1/2] efi/efi_test: use memdup_user Matt Fleming
2017-05-08  8:18   ` ivanhu
     [not found]     ` <0d6b6b9e-de5c-4eb2-f46a-d26ae058fa42-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
2017-05-10 10:35       ` Matt Fleming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).