Commit 161f440c authored by Kumar Amit Mehta's avatar Kumar Amit Mehta Committed by Greg Kroah-Hartman

staging: comedi: drivers: usbduxfast.c: fix for DMA buffers on stack

fix for instances of DMA buffer on stack(being passed to usb_control_msg) for
the USB-DUXfast Board driver.
Signed-off-by: default avatarKumar Amit Mehta <gmate.amit@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d49c3d61
...@@ -436,10 +436,14 @@ static void usbduxfastsub_ai_Irq(struct urb *urb) ...@@ -436,10 +436,14 @@ static void usbduxfastsub_ai_Irq(struct urb *urb)
static int usbduxfastsub_start(struct usbduxfastsub_s *udfs) static int usbduxfastsub_start(struct usbduxfastsub_s *udfs)
{ {
int ret; int ret;
unsigned char local_transfer_buffer[16]; unsigned char *local_transfer_buffer;
local_transfer_buffer = kmalloc(1, GFP_KERNEL);
if (!local_transfer_buffer)
return -ENOMEM;
/* 7f92 to zero */ /* 7f92 to zero */
local_transfer_buffer[0] = 0; *local_transfer_buffer = 0;
/* bRequest, "Firmware" */ /* bRequest, "Firmware" */
ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0), ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0),
USBDUXFASTSUB_FIRMWARE, USBDUXFASTSUB_FIRMWARE,
...@@ -450,22 +454,25 @@ static int usbduxfastsub_start(struct usbduxfastsub_s *udfs) ...@@ -450,22 +454,25 @@ static int usbduxfastsub_start(struct usbduxfastsub_s *udfs)
local_transfer_buffer, local_transfer_buffer,
1, /* Length */ 1, /* Length */
EZTIMEOUT); /* Timeout */ EZTIMEOUT); /* Timeout */
if (ret < 0) { if (ret < 0)
dev_err(&udfs->interface->dev, dev_err(&udfs->interface->dev,
"control msg failed (start)\n"); "control msg failed (start)\n");
return ret;
}
return 0; kfree(local_transfer_buffer);
return ret;
} }
static int usbduxfastsub_stop(struct usbduxfastsub_s *udfs) static int usbduxfastsub_stop(struct usbduxfastsub_s *udfs)
{ {
int ret; int ret;
unsigned char local_transfer_buffer[16]; unsigned char *local_transfer_buffer;
local_transfer_buffer = kmalloc(1, GFP_KERNEL);
if (!local_transfer_buffer)
return -ENOMEM;
/* 7f92 to one */ /* 7f92 to one */
local_transfer_buffer[0] = 1; *local_transfer_buffer = 1;
/* bRequest, "Firmware" */ /* bRequest, "Firmware" */
ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0), ret = usb_control_msg(udfs->usbdev, usb_sndctrlpipe(udfs->usbdev, 0),
USBDUXFASTSUB_FIRMWARE, USBDUXFASTSUB_FIRMWARE,
...@@ -474,13 +481,12 @@ static int usbduxfastsub_stop(struct usbduxfastsub_s *udfs) ...@@ -474,13 +481,12 @@ static int usbduxfastsub_stop(struct usbduxfastsub_s *udfs)
0x0000, /* Index */ 0x0000, /* Index */
local_transfer_buffer, 1, /* Length */ local_transfer_buffer, 1, /* Length */
EZTIMEOUT); /* Timeout */ EZTIMEOUT); /* Timeout */
if (ret < 0) { if (ret < 0)
dev_err(&udfs->interface->dev, dev_err(&udfs->interface->dev,
"control msg failed (stop)\n"); "control msg failed (stop)\n");
return ret;
}
return 0; kfree(local_transfer_buffer);
return ret;
} }
static int usbduxfastsub_upload(struct usbduxfastsub_s *udfs, static int usbduxfastsub_upload(struct usbduxfastsub_s *udfs,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment