[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1363666958-31991-1-git-send-email-gheorghiuandru@gmail.com>
Date: Tue, 19 Mar 2013 06:22:38 +0200
From: Alexandru Gheorghiu <gheorghiuandru@...il.com>
To: Nagalakshmi Nandigama <Nagalakshmi.Nandigama@....com>
Cc: Sreekanth Reddy <Sreekanth.Reddy@....com>, support@....com,
linux-kernel@...r.kernel.org,
Alexandru Gheorghiu <gheorghiuandru@...il.com>
Subject: [PATCH] drivers: message: fusion: Use memdup_user function
Used memdup_user function instead of kmalloc and copy_from_user.
Patch found using coccinelle.
Signed-off-by: Alexandru Gheorghiu <gheorghiuandru@...il.com>
---
drivers/message/fusion/mptctl.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index b383b69..2669e83 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -1268,19 +1268,12 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size)
else
return -EFAULT;
- karg = kmalloc(data_size, GFP_KERNEL);
- if (karg == NULL) {
- printk(KERN_ERR MYNAM "%s::mpt_ioctl_iocinfo() @%d - no memory available!\n",
- __FILE__, __LINE__);
- return -ENOMEM;
- }
-
- if (copy_from_user(karg, uarg, data_size)) {
+ karg = memdup_user(uarg, data_size);
+ if (IS_ERR(karg)) {
printk(KERN_ERR MYNAM "%s@%d::mptctl_getiocinfo - "
"Unable to read in mpt_ioctl_iocinfo struct @ %p\n",
__FILE__, __LINE__, uarg);
- kfree(karg);
- return -EFAULT;
+ return PTR_ERR(karg);
}
if (((iocnum = mpt_verify_adapter(karg->hdr.iocnum, &ioc)) < 0) ||
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists