lkml.org 
[lkml]   [2010]   [Sep]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    Subject[026/123] USB: mos7840: fix DMA buffers on stack and endianess bugs
    From: Johan Hovold <jhovold@gmail.com>

    commit 9e221a35f82cbef0397d81fed588bafba95b550c upstream.

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

    ---
    drivers/usb/serial/mos7840.c | 22 ++++++++++++++++++----
    1 file changed, 18 insertions(+), 4 deletions(-)

    --- a/drivers/usb/serial/mos7840.c
    +++ b/drivers/usb/serial/mos7840.c
    @@ -286,12 +286,19 @@ static int mos7840_get_reg_sync(struct u
    {
    struct usb_device *dev = port->serial->dev;
    int ret = 0;
    + u8 *buf;
    +
    + buf = kmalloc(VENDOR_READ_LENGTH, GFP_KERNEL);
    + if (!buf)
    + return -ENOMEM;

    ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
    - MCS_RD_RTYPE, 0, reg, val, VENDOR_READ_LENGTH,
    + MCS_RD_RTYPE, 0, reg, buf, VENDOR_READ_LENGTH,
    MOS_WDR_TIMEOUT);
    + *val = buf[0];
    dbg("mos7840_get_reg_sync offset is %x, return val %x", reg, *val);
    - *val = (*val) & 0x00ff;
    +
    + kfree(buf);
    return ret;
    }

    @@ -344,6 +351,11 @@ static int mos7840_get_uart_reg(struct u
    struct usb_device *dev = port->serial->dev;
    int ret = 0;
    __u16 Wval;
    + u8 *buf;
    +
    + buf = kmalloc(VENDOR_READ_LENGTH, GFP_KERNEL);
    + if (!buf)
    + return -ENOMEM;

    /* dbg("application number is %4x",
    (((__u16)port->number - (__u16)(port->serial->minor))+1)<<8); */
    @@ -367,9 +379,11 @@ static int mos7840_get_uart_reg(struct u
    }
    }
    ret = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0), MCS_RDREQ,
    - MCS_RD_RTYPE, Wval, reg, val, VENDOR_READ_LENGTH,
    + MCS_RD_RTYPE, Wval, reg, buf, VENDOR_READ_LENGTH,
    MOS_WDR_TIMEOUT);
    - *val = (*val) & 0x00ff;
    + *val = buf[0];
    +
    + kfree(buf);
    return ret;
    }




    \
     
     \ /
      Last update: 2010-09-18 21:15    [W:0.029 / U:0.316 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site