Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935188AbcJRPcK (ORCPT ); Tue, 18 Oct 2016 11:32:10 -0400 Received: from terminus.zytor.com ([198.137.202.10]:49808 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936430AbcJRPba (ORCPT ); Tue, 18 Oct 2016 11:31:30 -0400 Date: Tue, 18 Oct 2016 08:30:55 -0700 From: tip-bot for Ivan Hu Message-ID: Cc: tglx@linutronix.de, peterz@infradead.org, matt@codeblueprint.co.uk, linux-kernel@vger.kernel.org, mingo@kernel.org, ivan.khoronzhuk@linaro.org, hpa@zytor.com, torvalds@linux-foundation.org, ivan.hu@canonical.com, ard.biesheuvel@linaro.org Reply-To: mingo@kernel.org, torvalds@linux-foundation.org, ard.biesheuvel@linaro.org, ivan.hu@canonical.com, ivan.khoronzhuk@linaro.org, hpa@zytor.com, peterz@infradead.org, tglx@linutronix.de, matt@codeblueprint.co.uk, linux-kernel@vger.kernel.org In-Reply-To: <20161018143318.15673-7-matt@codeblueprint.co.uk> References: <20161018143318.15673-7-matt@codeblueprint.co.uk> To: linux-tip-commits@vger.kernel.org Subject: [tip:efi/core] efi/efi_test: Use memdup_user() as a cleanup Git-Commit-ID: c208ed916e587048ba6b69840d08324100d7d325 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 Content-Length: 1827 Lines: 51 Commit-ID: c208ed916e587048ba6b69840d08324100d7d325 Gitweb: http://git.kernel.org/tip/c208ed916e587048ba6b69840d08324100d7d325 Author: Ivan Hu AuthorDate: Tue, 18 Oct 2016 15:33:16 +0100 Committer: Ingo Molnar CommitDate: Tue, 18 Oct 2016 17:11:19 +0200 efi/efi_test: Use memdup_user() as a cleanup Fix coccicheck warning which recommends to use memdup_user(). This patch fixes the following coccicheck warnings: drivers/firmware/efi/test/efi_test.c:269:8-15: WARNING opportunity for memdup_user Signed-off-by: Ivan Hu Signed-off-by: Matt Fleming Cc: Ard Biesheuvel Cc: Ivan Khoronzhuk Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: http://lkml.kernel.org/r/20161018143318.15673-7-matt@codeblueprint.co.uk Signed-off-by: Ingo Molnar --- drivers/firmware/efi/test/efi_test.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/firmware/efi/test/efi_test.c b/drivers/firmware/efi/test/efi_test.c index bb26e12..8cd578f 100644 --- a/drivers/firmware/efi/test/efi_test.c +++ b/drivers/firmware/efi/test/efi_test.c @@ -265,14 +265,10 @@ static long efi_runtime_set_variable(unsigned long arg) return rv; } - data = kmalloc(setvariable.data_size, GFP_KERNEL); - if (!data) { + data = memdup_user(setvariable.data, setvariable.data_size); + if (IS_ERR(data)) { kfree(name); - return -ENOMEM; - } - if (copy_from_user(data, setvariable.data, setvariable.data_size)) { - rv = -EFAULT; - goto out; + return PTR_ERR(data); } status = efi.set_variable(name, &vendor_guid,