lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 5 Jun 2017 10:15:29 -0700
From:   tip-bot for Geliang Tang <tipbot@...or.com>
To:     linux-tip-commits@...r.kernel.org
Cc:     geliangtang@...il.com, tglx@...utronix.de,
        ard.biesheuvel@...aro.org, linux-kernel@...r.kernel.org,
        mingo@...nel.org, ivan.hu@...onical.com, peterz@...radead.org,
        matt@...eblueprint.co.uk, hpa@...or.com,
        torvalds@...ux-foundation.org
Subject: [tip:efi/core] efi/efi_test: Use memdup_user() helper

Commit-ID:  5f72cad65cfaac5e40d0de8b7f48ee647af69cd5
Gitweb:     http://git.kernel.org/tip/5f72cad65cfaac5e40d0de8b7f48ee647af69cd5
Author:     Geliang Tang <geliangtang@...il.com>
AuthorDate: Fri, 2 Jun 2017 13:52:05 +0000
Committer:  Ingo Molnar <mingo@...nel.org>
CommitDate: Mon, 5 Jun 2017 17:50:42 +0200

efi/efi_test: Use memdup_user() helper

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

Signed-off-by: Geliang Tang <geliangtang@...il.com>
Signed-off-by: Matt Fleming <matt@...eblueprint.co.uk>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@...aro.org>
Acked-by: Ivan Hu <ivan.hu@...onical.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: linux-efi@...r.kernel.org
Link: http://lkml.kernel.org/r/20170602135207.21708-12-ard.biesheuvel@linaro.org
Signed-off-by: Ingo Molnar <mingo@...nel.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;
 }
 

Powered by blists - more mailing lists