lkml.org 
[lkml]   [2013]   [Jun]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[ 25/79] USB: mos7720: fix DMA to stack
    Date
    3.9-stable review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Johan Hovold <jhovold@gmail.com>

    commit 72ea18a558ed7a63a50bb121ba60d73b5b38ae30 upstream.

    The read_mos_reg function is called with stack-allocated buffers, which
    must not be used for control messages.

    Signed-off-by: Johan Hovold <jhovold@gmail.com>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

    ---
    drivers/usb/serial/mos7720.c | 17 ++++++++++++++---
    1 file changed, 14 insertions(+), 3 deletions(-)

    --- a/drivers/usb/serial/mos7720.c
    +++ b/drivers/usb/serial/mos7720.c
    @@ -228,11 +228,22 @@ static int read_mos_reg(struct usb_seria
    __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;
    }




    \
     
     \ /
      Last update: 2013-06-12 01:41    [W:5.406 / U:0.076 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site