[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1471948054-15651-1-git-send-email-sudipm.mukherjee@gmail.com>
Date: Tue, 23 Aug 2016 15:57:34 +0530
From: Sudip Mukherjee <sudipm.mukherjee@...il.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: linux-kernel@...r.kernel.org, devel@...verdev.osuosl.org,
Sudip Mukherjee <sudipm.mukherjee@...il.com>,
Fengguang Wu <fengguang.wu@...el.com>
Subject: [PATCH] staging: i4l: icn: use memdup_user
Its better to use memdup_user which does the same thing which this
code has implemented.
Suggested-by: Fengguang Wu <fengguang.wu@...el.com>
Signed-off-by: Sudip Mukherjee <sudip.mukherjee@...ethink.co.uk>
---
drivers/staging/i4l/icn/icn.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/staging/i4l/icn/icn.c b/drivers/staging/i4l/icn/icn.c
index b2f4055..5312675 100644
--- a/drivers/staging/i4l/icn/icn.c
+++ b/drivers/staging/i4l/icn/icn.c
@@ -804,21 +804,16 @@ static int
icn_loadboot(u_char __user *buffer, icn_card *card)
{
int ret;
- u_char *codebuf;
+ void *codebuf;
unsigned long flags;
#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)) {
+ pr_warn("icn: Could not allocate code buffer\n");
+ return PTR_ERR(codebuf);
}
if (!card->rvalid) {
if (!request_region(card->port, ICN_PORTLEN, card->regname)) {
@@ -902,7 +897,6 @@ icn_loadboot(u_char __user *buffer, icn_card *card)
out_kfree:
kfree(codebuf);
-out:
return ret;
}
--
1.9.1
Powered by blists - more mailing lists