Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1503055

[PATCH 6/8] efi/efi_test: Use memdup_user() as a cleanup

From Matt Fleming <matt@codeblueprint.co.uk>
Newsgroups linux.kernel
Subject [PATCH 6/8] efi/efi_test: Use memdup_user() as a cleanup
Date 2016-10-18 16:40 +0200
Message-ID <stDID-2X6-71@gated-at.bofh.it> (permalink)
References <stDIC-2X6-35@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Ivan Hu <ivan.hu@canonical.com>

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 <ivan.hu@canonical.com>
Cc: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
---
 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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL 0/8] EFI changes for v4.10 Matt Fleming <matt@codeblueprint.co.uk> - 2016-10-18 16:40 +0200
  [PATCH 1/8] MAINTAINERS: add myself as EFI maintainer Matt Fleming <matt@codeblueprint.co.uk> - 2016-10-18 16:40 +0200
    [tip:efi/core] MAINTAINERS: Add myself as EFI maintainer tip-bot for Ard Biesheuvel <tipbot@zytor.com> - 2016-10-18 17:40 +0200
  [PATCH 3/8] efi/arm*: efi_init() error handling fix Matt Fleming <matt@codeblueprint.co.uk> - 2016-10-18 16:40 +0200
    [tip:efi/core] efi/arm*: Fix efi_init() error handling tip-bot for Yisheng Xie <tipbot@zytor.com> - 2016-10-18 17:40 +0200
  [PATCH 2/8] efi: Remove unused including <linux/version.h> Matt Fleming <matt@codeblueprint.co.uk> - 2016-10-18 16:40 +0200
    [tip:efi/core] efi: Remove unused include of <linux/version.h> tip-bot for Wei Yongjun <tipbot@zytor.com> - 2016-10-18 17:40 +0200
  [PATCH 4/8] efi/efi_test: Fix the uninitialized value datasize Matt Fleming <matt@codeblueprint.co.uk> - 2016-10-18 16:40 +0200
    [tip:efi/core] efi/efi_test: Fix uninitialized variable 'datasize' tip-bot for Ivan Hu <tipbot@zytor.com> - 2016-10-18 17:40 +0200
  [PATCH 5/8] efi/efi_test: Fix the uninitialized value rv Matt Fleming <matt@codeblueprint.co.uk> - 2016-10-18 16:40 +0200
    [tip:efi/core] efi/efi_test: Fix uninitialized variable 'rv' tip-bot for Ivan Hu <tipbot@zytor.com> - 2016-10-18 17:40 +0200
  [PATCH 6/8] efi/efi_test: Use memdup_user() as a cleanup Matt Fleming <matt@codeblueprint.co.uk> - 2016-10-18 16:40 +0200
    [tip:efi/core] efi/efi_test: Use memdup_user() as a cleanup tip-bot for Ivan Hu <tipbot@zytor.com> - 2016-10-18 17:40 +0200
  [PATCH 8/8] efi: efivar_ssdt_load: Don't return success on allocation failure Matt Fleming <matt@codeblueprint.co.uk> - 2016-10-18 16:40 +0200
    [tip:efi/core] efi/efivar_ssdt_load: Don't return success on  allocation failure tip-bot for Dan Carpenter <tipbot@zytor.com> - 2016-10-18 17:40 +0200
  Re: [GIT PULL 0/8] EFI changes for v4.10 Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-10-18 17:30 +0200
  Re: [GIT PULL 0/8] EFI changes for v4.10 Ingo Molnar <mingo@kernel.org> - 2016-10-18 17:30 +0200
  Re: [GIT PULL 0/8] EFI changes for v4.10 Lukas Wunner <lukas@wunner.de> - 2016-10-18 17:40 +0200
    Re: [GIT PULL 0/8] EFI changes for v4.10 Matt Fleming <matt@codeblueprint.co.uk> - 2016-10-18 17:50 +0200

csiph-web