From: Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
To: Ingo Molnar <mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>,
"H . Peter Anvin" <hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org>
Cc: Ivan Hu <ivan.hu-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>,
Ard Biesheuvel
<ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Matt Fleming
<matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>,
Ivan Khoronzhuk
<ivan.khoronzhuk-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: [PATCH 6/8] efi/efi_test: Use memdup_user() as a cleanup
Date: Tue, 18 Oct 2016 15:33:16 +0100 [thread overview]
Message-ID: <20161018143318.15673-7-matt@codeblueprint.co.uk> (raw)
In-Reply-To: <20161018143318.15673-1-matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
From: Ivan Hu <ivan.hu-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
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-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org>
Cc: Ivan Khoronzhuk <ivan.khoronzhuk-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Cc: Ard Biesheuvel <ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Signed-off-by: Matt Fleming <matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
---
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
WARNING: multiple messages have this Message-ID (diff)
From: Matt Fleming <matt@codeblueprint.co.uk>
To: Ingo Molnar <mingo@kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
"H . Peter Anvin" <hpa@zytor.com>
Cc: Ivan Hu <ivan.hu@canonical.com>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org,
Matt Fleming <matt@codeblueprint.co.uk>,
Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Subject: [PATCH 6/8] efi/efi_test: Use memdup_user() as a cleanup
Date: Tue, 18 Oct 2016 15:33:16 +0100 [thread overview]
Message-ID: <20161018143318.15673-7-matt@codeblueprint.co.uk> (raw)
In-Reply-To: <20161018143318.15673-1-matt@codeblueprint.co.uk>
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
next prev parent reply other threads:[~2016-10-18 14:33 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-18 14:33 [GIT PULL 0/8] EFI changes for v4.10 Matt Fleming
2016-10-18 14:33 ` Matt Fleming
[not found] ` <20161018143318.15673-1-matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>
2016-10-18 14:33 ` [PATCH 1/8] MAINTAINERS: add myself as EFI maintainer Matt Fleming
2016-10-18 14:33 ` Matt Fleming
2016-10-18 15:28 ` [tip:efi/core] MAINTAINERS: Add " tip-bot for Ard Biesheuvel
2016-10-18 14:33 ` [PATCH 2/8] efi: Remove unused including <linux/version.h> Matt Fleming
2016-10-18 14:33 ` Matt Fleming
2016-10-18 15:28 ` [tip:efi/core] efi: Remove unused include of <linux/version.h> tip-bot for Wei Yongjun
2016-10-18 14:33 ` [PATCH 3/8] efi/arm*: efi_init() error handling fix Matt Fleming
2016-10-18 14:33 ` Matt Fleming
2016-10-18 15:29 ` [tip:efi/core] efi/arm*: Fix efi_init() error handling tip-bot for Yisheng Xie
2016-10-18 14:33 ` [PATCH 4/8] efi/efi_test: Fix the uninitialized value datasize Matt Fleming
2016-10-18 14:33 ` Matt Fleming
2016-10-18 15:29 ` [tip:efi/core] efi/efi_test: Fix uninitialized variable 'datasize' tip-bot for Ivan Hu
2016-10-18 14:33 ` [PATCH 5/8] efi/efi_test: Fix the uninitialized value rv Matt Fleming
2016-10-18 14:33 ` Matt Fleming
2016-10-18 15:30 ` [tip:efi/core] efi/efi_test: Fix uninitialized variable 'rv' tip-bot for Ivan Hu
2016-10-18 14:33 ` Matt Fleming [this message]
2016-10-18 14:33 ` [PATCH 6/8] efi/efi_test: Use memdup_user() as a cleanup Matt Fleming
2016-10-18 15:30 ` [tip:efi/core] " tip-bot for Ivan Hu
2016-10-18 15:34 ` [GIT PULL 0/8] EFI changes for v4.10 Lukas Wunner
2016-10-18 15:34 ` Lukas Wunner
[not found] ` <20161018153436.GA2593-JFq808J9C/izQB+pC5nmwQ@public.gmane.org>
2016-10-18 15:40 ` Matt Fleming
2016-10-18 15:40 ` Matt Fleming
2016-10-18 14:33 ` [PATCH 7/8] efifb: show framebuffer layout as device attributes Matt Fleming
2016-10-18 15:31 ` [tip:efi/core] efifb: Show " tip-bot for Peter Jones
2016-10-18 14:33 ` [PATCH 8/8] efi: efivar_ssdt_load: Don't return success on allocation failure Matt Fleming
2016-10-18 15:31 ` [tip:efi/core] efi/efivar_ssdt_load: " tip-bot for Dan Carpenter
2016-10-18 15:25 ` [GIT PULL 0/8] EFI changes for v4.10 Ingo Molnar
[not found] ` <20161018152556.GA27061-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-10-18 15:29 ` Ard Biesheuvel
2016-10-18 15:29 ` Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161018143318.15673-7-matt@codeblueprint.co.uk \
--to=matt-mf/unelci9gs6ibeejttw/xrex20p6io@public.gmane.org \
--cc=ard.biesheuvel-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=hpa-YMNOUZJC4hwAvxtiuMwx3w@public.gmane.org \
--cc=ivan.hu-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org \
--cc=ivan.khoronzhuk-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mingo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.