Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934703AbcJROeM (ORCPT ); Tue, 18 Oct 2016 10:34:12 -0400 Received: from mail-qt0-f169.google.com ([209.85.216.169]:32990 "EHLO mail-qt0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761368AbcJROdb (ORCPT ); Tue, 18 Oct 2016 10:33:31 -0400 From: Matt Fleming To: Ingo Molnar , Thomas Gleixner , "H . Peter Anvin" Cc: Ivan Hu , Ard Biesheuvel , linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, Matt Fleming , Ivan Khoronzhuk Subject: [PATCH 6/8] efi/efi_test: Use memdup_user() as a cleanup Date: Tue, 18 Oct 2016 15:33:16 +0100 Message-Id: <20161018143318.15673-7-matt@codeblueprint.co.uk> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161018143318.15673-1-matt@codeblueprint.co.uk> References: <20161018143318.15673-1-matt@codeblueprint.co.uk> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1232 Lines: 40 From: Ivan Hu Fix coccicheck warning which recommends to use memdup_user() This patch fixes below coccicheck warnings: drivers/firmware/efi/test/efi_test.c:269:8-15: WARNING opportunity for memdup_user Signed-off-by: Ivan Hu Cc: Ivan Khoronzhuk Cc: Ard Biesheuvel Signed-off-by: Matt Fleming --- 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 bb26e12b0cfd..8cd578f62059 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, -- 2.10.0