USB: usbtmc: fix DMA on stack
authorOliver Neukum <oneukum@suse.de>
Mon, 19 May 2014 11:54:57 +0000 (13:54 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 May 2014 23:03:57 +0000 (16:03 -0700)
send_request_dev_dep_msg_in() use a buffer allocated on the stack.
Fix by kmalloc()ing the buffer.

Signed-off-by: Oliver Neukum <oneukum@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/class/usbtmc.c

index cfbec9c7e09e1c13019a0ebd0780ccc2d0e6adba..103a6e9ee49d0a473bf29037a352f043a07c6068 100644 (file)
@@ -383,9 +383,12 @@ exit:
 static int send_request_dev_dep_msg_in(struct usbtmc_device_data *data, size_t transfer_size)
 {
        int retval;
-       u8 buffer[USBTMC_HEADER_SIZE];
+       u8 *buffer;
        int actual;
 
+       buffer = kmalloc(USBTMC_HEADER_SIZE, GFP_KERNEL);
+       if (!buffer)
+               return -ENOMEM;
        /* Setup IO buffer for REQUEST_DEV_DEP_MSG_IN message
         * Refer to class specs for details
         */
@@ -417,6 +420,7 @@ static int send_request_dev_dep_msg_in(struct usbtmc_device_data *data, size_t t
        if (!data->bTag)
                data->bTag++;
 
+       kfree(buffer);
        if (retval < 0) {
                dev_err(&data->intf->dev, "usb_bulk_msg in send_request_dev_dep_msg_in() returned %d\n", retval);
                return retval;