Skip to contentSkip to conversation

efi/efi_test: use memdup_user() as a cleanup

PATCH Applied Ivan Hu 2 participants 2 messages Oct 5, 2016 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Ivan Hu

author
#0 lore raw

PATCH v2 1/3 efi/efi_test: use memdup_user() as a cleanup

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

---
 drivers/firmware/efi/test/efi_test.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/firmware/efi/test/efi_test.c +3 -7
index f61bb52..5602c46 100644
@@ -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,
Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): 1475633254-6815-1-git-send-email-ivan.hu-Z7WLFzj8eWMS+FvcfC7Uqw@public.gmane.org

Applied
#2 lore raw
Quoted 10 lines · 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

---
 drivers/firmware/efi/test/efi_test.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

Thanks, applied to 'next'.