staging: gasket: avoid copy to user on error in coherent alloc config
authorTodd Poynor <toddpoynor@google.com>
Sat, 21 Jul 2018 13:34:57 +0000 (06:34 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Jul 2018 11:56:45 +0000 (13:56 +0200)
gasket_config_coherent_allocator() on error return the error to caller
without copying a possibly-update DMA address back to userspace.

Reported-by: Dmitry Torokhov <dtor@chromium.org>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/gasket/gasket_ioctl.c

index 1b164ac7a049605670067f1f0fcc9e10132726c4..8cf094b90cdb0748e738aa8e57ee78589f734b53 100644 (file)
@@ -441,8 +441,10 @@ static int gasket_config_coherent_allocator(
                        gasket_dev, ibuf.size, &ibuf.dma_address,
                        ibuf.page_table_index);
        }
+       if (ret)
+               return ret;
        if (copy_to_user(argp, &ibuf, sizeof(ibuf)))
                return -EFAULT;
 
-       return ret;
+       return 0;
 }