]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mptfusion: use memdup_user
authorJoe Lawrence <joe.lawrence@stratus.com>
Wed, 25 Jun 2014 21:06:12 +0000 (17:06 -0400)
committerChristoph Hellwig <hch@lst.de>
Fri, 25 Jul 2014 21:16:57 +0000 (17:16 -0400)
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>
drivers/message/fusion/mptctl.c

index 8a050e8856881ada1094954c5ce04f9584ed36e7..b0a892a2bf1b535ac4b155c92dbca0bacaad990a 100644 (file)
@@ -1261,19 +1261,11 @@ 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)) {
-               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;
+       karg = memdup_user(uarg, data_size);
+       if (IS_ERR(karg)) {
+               printk(KERN_ERR MYNAM "%s@%d::mpt_ioctl_iocinfo() - memdup_user returned error [%ld]\n",
+                               __FILE__, __LINE__, PTR_ERR(karg));
+               return PTR_ERR(karg);
        }
 
        if (((iocnum = mpt_verify_adapter(karg->hdr.iocnum, &ioc)) < 0) ||