summaryrefslogtreecommitdiff
path: root/drivers/usb/serial/mos7720.c
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2013-05-27 14:44:39 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-05-29 10:50:41 +0900
commit72ea18a558ed7a63a50bb121ba60d73b5b38ae30 (patch)
treed7a4edbe16735e3b426034748af99f9d2bac10d6 /drivers/usb/serial/mos7720.c
parent420021a395ce38b7ab2cceb52dee4038be7d8fa3 (diff)
USB: mos7720: fix DMA to stack
The read_mos_reg function is called with stack-allocated buffers, which must not be used for control messages. Cc: stable@vger.kernel.org Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/serial/mos7720.c')
-rw-r--r--drivers/usb/serial/mos7720.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c
index cc0e54345df9..7752cffbf2bc 100644
--- a/drivers/usb/serial/mos7720.c
+++ b/drivers/usb/serial/mos7720.c
@@ -227,11 +227,22 @@ static int read_mos_reg(struct usb_serial *serial, unsigned int serial_portnum,
__u8 requesttype = (__u8)0xc0;
__u16 index = get_reg_index(reg);
__u16 value = get_reg_value(reg, serial_portnum);
- int status = usb_control_msg(usbdev, pipe, request, requesttype, value,
- index, data, 1, MOS_WDR_TIMEOUT);
- if (status < 0)
+ u8 *buf;
+ int status;
+
+ buf = kmalloc(1, GFP_KERNEL);
+ if (!buf)
+ return -ENOMEM;
+
+ status = usb_control_msg(usbdev, pipe, request, requesttype, value,
+ index, buf, 1, MOS_WDR_TIMEOUT);
+ if (status == 1)
+ *data = *buf;
+ else if (status < 0)
dev_err(&usbdev->dev,
"mos7720: usb_control_msg() failed: %d", status);
+ kfree(buf);
+
return status;
}