aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message
diff options
context:
space:
mode:
authorJoe Lawrence <joe.lawrence@stratus.com>2014-06-25 17:06:12 -0400
committerChristoph Hellwig <hch@lst.de>2014-07-25 17:16:57 -0400
commit3e67c459d0ac945ac09639d85de299e65317aefe (patch)
tree2dcf88d2311361e90e102d1c74b757c0d23f0fb5 /drivers/message
parent5074b1b60edd47e0ce4485e57990f7ca75c3e67e (diff)
mptfusion: use memdup_user
Let memdup_user handle the kmalloc, copy_from_user and error checking kfree code. Spotted by the following smatch (false positive) warning: drivers/message/fusion/mptctl.c:1369 mptctl_getiocinfo() warn: possible info leak 'karg' Signed-off-by: Joe Lawrence <joe.lawrence@stratus.com> Acked-by: Sreekanth Reddy <Sreekanth.Reddy@avagotech.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/message')
-rw-r--r--drivers/message/fusion/mptctl.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index 8a050e885688..b0a892a2bf1b 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -1261,19 +1261,11 @@ mptctl_getiocinfo (unsigned long arg, unsigned int data_size)
1261 else 1261 else
1262 return -EFAULT; 1262 return -EFAULT;
1263 1263
1264 karg = kmalloc(data_size, GFP_KERNEL); 1264 karg = memdup_user(uarg, data_size);
1265 if (karg == NULL) { 1265 if (IS_ERR(karg)) {
1266 printk(KERN_ERR MYNAM "%s::mpt_ioctl_iocinfo() @%d - no memory available!\n", 1266 printk(KERN_ERR MYNAM "%s@%d::mpt_ioctl_iocinfo() - memdup_user returned error [%ld]\n",
1267 __FILE__, __LINE__); 1267 __FILE__, __LINE__, PTR_ERR(karg));
1268 return -ENOMEM; 1268 return PTR_ERR(karg);
1269 }
1270
1271 if (copy_from_user(karg, uarg, data_size)) {
1272 printk(KERN_ERR MYNAM "%s@%d::mptctl_getiocinfo - "
1273 "Unable to read in mpt_ioctl_iocinfo struct @ %p\n",
1274 __FILE__, __LINE__, uarg);
1275 kfree(karg);
1276 return -EFAULT;
1277 } 1269 }
1278 1270
1279 if (((iocnum = mpt_verify_adapter(karg->hdr.iocnum, &ioc)) < 0) || 1271 if (((iocnum = mpt_verify_adapter(karg->hdr.iocnum, &ioc)) < 0) ||