summaryrefslogtreecommitdiffstats
path: root/drivers/staging/i4l
diff options
context:
space:
mode:
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>2016-08-23 19:43:21 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-08-31 09:24:04 +0200
commitb91796e86b30ffa8e01f4b06f7a81e724c760b6d (patch)
tree5dec907ff68e9ba17cc8ab1cd9cb98b1bc0dcbd0 /drivers/staging/i4l
parent3b1d75332ea7e397d8127b8d39d1f59ed60e49d2 (diff)
downloadop-kernel-dev-b91796e86b30ffa8e01f4b06f7a81e724c760b6d.zip
op-kernel-dev-b91796e86b30ffa8e01f4b06f7a81e724c760b6d.tar.gz
staging: i4l: icn: use memdup_user
Its better to use memdup_user which does the same thing which this code has implemented. Also removed a related warning as we will be warned if allocation fails. Suggested-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/i4l')
-rw-r--r--drivers/staging/i4l/icn/icn.c15
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/staging/i4l/icn/icn.c b/drivers/staging/i4l/icn/icn.c
index b2f4055..415124f 100644
--- a/drivers/staging/i4l/icn/icn.c
+++ b/drivers/staging/i4l/icn/icn.c
@@ -810,16 +810,10 @@ icn_loadboot(u_char __user *buffer, icn_card *card)
#ifdef BOOT_DEBUG
printk(KERN_DEBUG "icn_loadboot called, buffaddr=%08lx\n", (ulong) buffer);
#endif
- codebuf = kmalloc(ICN_CODE_STAGE1, GFP_KERNEL);
- if (!codebuf) {
- printk(KERN_WARNING "icn: Could not allocate code buffer\n");
- ret = -ENOMEM;
- goto out;
- }
- if (copy_from_user(codebuf, buffer, ICN_CODE_STAGE1)) {
- ret = -EFAULT;
- goto out_kfree;
- }
+ codebuf = memdup_user(buffer, ICN_CODE_STAGE1);
+ if (IS_ERR(codebuf))
+ return PTR_ERR(codebuf);
+
if (!card->rvalid) {
if (!request_region(card->port, ICN_PORTLEN, card->regname)) {
printk(KERN_WARNING
@@ -902,7 +896,6 @@ icn_loadboot(u_char __user *buffer, icn_card *card)
out_kfree:
kfree(codebuf);
-out:
return ret;
}
OpenPOWER on IntegriCloud