* [PATCH] drivers: message: fusion: Use memdup_user function
@ 2013-03-19 4:22 Alexandru Gheorghiu
0 siblings, 0 replies; only message in thread
From: Alexandru Gheorghiu @ 2013-03-19 4:22 UTC (permalink / raw)
To: Nagalakshmi Nandigama
Cc: Sreekanth Reddy, support, linux-kernel, Alexandru Gheorghiu
Used memdup_user function instead of kmalloc and copy_from_user.
Patch found using coccinelle.
Signed-off-by: Alexandru Gheorghiu <gheorghiuandru@gmail.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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-03-19 13:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-19 4:22 [PATCH] drivers: message: fusion: Use memdup_user function Alexandru Gheorghiu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®