From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752348AbdFERVM (ORCPT ); Mon, 5 Jun 2017 13:21:12 -0400 Received: from terminus.zytor.com ([65.50.211.136]:44121 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752125AbdFERVJ (ORCPT ); Mon, 5 Jun 2017 13:21:09 -0400 Date: Mon, 5 Jun 2017 10:15:29 -0700 From: tip-bot for Geliang Tang Message-ID: Cc: geliangtang@gmail.com, tglx@linutronix.de, ard.biesheuvel@linaro.org, linux-kernel@vger.kernel.org, mingo@kernel.org, ivan.hu@canonical.com, peterz@infradead.org, matt@codeblueprint.co.uk, hpa@zytor.com, torvalds@linux-foundation.org Reply-To: matt@codeblueprint.co.uk, hpa@zytor.com, torvalds@linux-foundation.org, mingo@kernel.org, peterz@infradead.org, ivan.hu@canonical.com, geliangtang@gmail.com, linux-kernel@vger.kernel.org, ard.biesheuvel@linaro.org, tglx@linutronix.de In-Reply-To: <20170602135207.21708-12-ard.biesheuvel@linaro.org> References: <20170602135207.21708-12-ard.biesheuvel@linaro.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:efi/core] efi/efi_test: Use memdup_user() helper Git-Commit-ID: 5f72cad65cfaac5e40d0de8b7f48ee647af69cd5 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 5f72cad65cfaac5e40d0de8b7f48ee647af69cd5 Gitweb: http://git.kernel.org/tip/5f72cad65cfaac5e40d0de8b7f48ee647af69cd5 Author: Geliang Tang AuthorDate: Fri, 2 Jun 2017 13:52:05 +0000 Committer: Ingo Molnar 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 Signed-off-by: Matt Fleming Signed-off-by: Ard Biesheuvel Acked-by: Ivan Hu Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20170602135207.21708-12-ard.biesheuvel@linaro.org Signed-off-by: Ingo Molnar --- 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; }