lkml.org 
[lkml]   [2021]   [Aug]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 08/10] staging: r8188eu: clean up the usb_writeN
    Date
    Remove unnecessary variables, check the length.

    Signed-off-by: Martin Kaiser <martin@kaiser.cx>
    ---
    drivers/staging/r8188eu/hal/usb_ops_linux.c | 15 +++++----------
    1 file changed, 5 insertions(+), 10 deletions(-)

    diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c
    index e01f1ac19596..5408383ccec3 100644
    --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c
    +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c
    @@ -151,20 +151,15 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val)

    static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata)
    {
    - u16 wvalue;
    - u16 len;
    + u16 wvalue = (u16)(addr & 0x0000ffff);
    u8 buf[VENDOR_CMD_MAX_DATA_LEN] = {0};
    - int ret;
    -

    + if (length > VENDOR_CMD_MAX_DATA_LEN)
    + return -EINVAL;

    - wvalue = (u16)(addr & 0x0000ffff);
    - len = length;
    - memcpy(buf, pdata, len);
    + memcpy(buf, pdata, length);

    - ret = usbctrl_vendorreq(pintfhdl, wvalue, buf, len, REALTEK_USB_VENQT_WRITE);
    -
    - return ret;
    + return usbctrl_vendorreq(pintfhdl, wvalue, buf, (length & 0xffff), REALTEK_USB_VENQT_WRITE);
    }

    static void interrupt_handler_8188eu(struct adapter *adapt, u16 pkt_len, u8 *pbuf)
    --
    2.20.1
    \
     
     \ /
      Last update: 2021-08-21 18:51    [W:2.801 / U:1.056 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site