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

staging: comedi: drivers: usbdux.c: fix DMA buffers on stack

fix for instances of DMA buffer on stack(being passed to usb_control_msg) for
the USB-DUX-D Board driver.
Signed-off-by: default avatarKumar Amit Mehta <gmate.amit@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6987a6da
...@@ -730,10 +730,14 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb) ...@@ -730,10 +730,14 @@ static void usbduxsub_ao_IsocIrq(struct urb *urb)
static int usbduxsub_start(struct usbduxsub *usbduxsub) static int usbduxsub_start(struct usbduxsub *usbduxsub)
{ {
int errcode = 0; int errcode = 0;
uint8_t local_transfer_buffer[16]; uint8_t *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;
errcode = usb_control_msg(usbduxsub->usbdev, errcode = usb_control_msg(usbduxsub->usbdev,
/* create a pipe for a control transfer */ /* create a pipe for a control transfer */
usb_sndctrlpipe(usbduxsub->usbdev, 0), usb_sndctrlpipe(usbduxsub->usbdev, 0),
...@@ -751,22 +755,25 @@ static int usbduxsub_start(struct usbduxsub *usbduxsub) ...@@ -751,22 +755,25 @@ static int usbduxsub_start(struct usbduxsub *usbduxsub)
1, 1,
/* Timeout */ /* Timeout */
BULK_TIMEOUT); BULK_TIMEOUT);
if (errcode < 0) { if (errcode < 0)
dev_err(&usbduxsub->interface->dev, dev_err(&usbduxsub->interface->dev,
"comedi_: control msg failed (start)\n"); "comedi_: control msg failed (start)\n");
kfree(local_transfer_buffer);
return errcode; return errcode;
}
return 0;
} }
static int usbduxsub_stop(struct usbduxsub *usbduxsub) static int usbduxsub_stop(struct usbduxsub *usbduxsub)
{ {
int errcode = 0; int errcode = 0;
uint8_t *local_transfer_buffer;
uint8_t local_transfer_buffer[16]; 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;
errcode = usb_control_msg(usbduxsub->usbdev, errcode = usb_control_msg(usbduxsub->usbdev,
usb_sndctrlpipe(usbduxsub->usbdev, 0), usb_sndctrlpipe(usbduxsub->usbdev, 0),
/* bRequest, "Firmware" */ /* bRequest, "Firmware" */
...@@ -781,12 +788,12 @@ static int usbduxsub_stop(struct usbduxsub *usbduxsub) ...@@ -781,12 +788,12 @@ static int usbduxsub_stop(struct usbduxsub *usbduxsub)
1, 1,
/* Timeout */ /* Timeout */
BULK_TIMEOUT); BULK_TIMEOUT);
if (errcode < 0) { if (errcode < 0)
dev_err(&usbduxsub->interface->dev, dev_err(&usbduxsub->interface->dev,
"comedi_: control msg failed (stop)\n"); "comedi_: control msg failed (stop)\n");
kfree(local_transfer_buffer);
return errcode; return errcode;
}
return 0;
} }
static int usbduxsub_upload(struct usbduxsub *usbduxsub, static int usbduxsub_upload(struct usbduxsub *usbduxsub,
......
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