Hi Matt,
The warning message is from Kbuild test robot,
https://chromium.googlesource.com/linux-fpga-chameleon/+/fpga-chameleon-4.2/scripts/coccinelle/api/memdup_user.cocci,
and I believe it tries to persuade us to use memdup_user instead of
kmalloc and copy_form_user,
With this new function, we don't have to write 'len' twice, which can
lead to typos/mistakes.
It also produces smaller code and kernel text.
http://lkml.iu.edu/hypermail/linux/kernel/0903.0/02349.html
Cheers,
Ivan
On 2016年10月04日 04:17, Matt Fleming wrote:
On Mon, 26 Sep, at 11:14:49AM, Ivan Hu wrote:
Cleanup the warning,
drivers/firmware/efi/test/efi_test.c:269:8-15: WARNING opportunity for
memdup_user
Use memdup_user rather than duplicating its implementation
This is a little bit restricted to reduce false positives
I don't understand this sentence. What restriction are you talking
about?
Generated by: coccinelle/api/memdup_user.coc
Signed-off-by: Ivan Hu <ivan.hu@xxxxxxxxxxxxx>
---
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 f61bb52..5602c46 100644
--- a/drivers/firmware/efi/test/efi_test.c
+++ b/drivers/firmware/efi/test/efi_test.c
@@ -266,14 +266,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,
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-efi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html