]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mtip32xx: don't open-code memdup_user()
authorAl Viro <viro@zeniv.linux.org.uk>
Sat, 2 Jan 2016 19:56:33 +0000 (14:56 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 6 Jan 2016 13:24:39 +0000 (08:24 -0500)
[folded a fix by Dan Carpenter]

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
drivers/block/mtip32xx/mtip32xx.c

index 3457ac8c03e2f3cfe10c8a2ccc26f9a706039831..34997d8ecd64b40d30db036a05dfc476e356111e 100644 (file)
@@ -2029,13 +2029,10 @@ static int exec_drive_taskfile(struct driver_data *dd,
        }
 
        if (taskout) {
-               outbuf = kzalloc(taskout, GFP_KERNEL);
-               if (outbuf == NULL) {
-                       err = -ENOMEM;
-                       goto abort;
-               }
-               if (copy_from_user(outbuf, buf + outtotal, taskout)) {
-                       err = -EFAULT;
+               outbuf = memdup_user(buf + outtotal, taskout);
+               if (IS_ERR(outbuf)) {
+                       err = PTR_ERR(outbuf);
+                       outbuf = NULL;
                        goto abort;
                }
                outbuf_dma = pci_map_single(dd->pdev,
@@ -2050,14 +2047,10 @@ static int exec_drive_taskfile(struct driver_data *dd,
        }
 
        if (taskin) {
-               inbuf = kzalloc(taskin, GFP_KERNEL);
-               if (inbuf == NULL) {
-                       err = -ENOMEM;
-                       goto abort;
-               }
-
-               if (copy_from_user(inbuf, buf + intotal, taskin)) {
-                       err = -EFAULT;
+               inbuf = memdup_user(buf + intotal, taskin);
+               if (IS_ERR(inbuf)) {
+                       err = PTR_ERR(inbuf);
+                       inbuf = NULL;
                        goto abort;
                }
                inbuf_dma = pci_map_single(dd->pdev,