Commit 59f73e2a authored by Amitkumar Karwar's avatar Amitkumar Karwar Committed by Kalle Valo

rsi: check length before USB read/write register

These checks are required. Otherwise we may end up getting
memory corruption if invalid length is passed.

Fixes: b97e9b94 ("rsi: Add new host interface operations")
Signed-off-by: default avatarAmitkumar Karwar <amit.karwar@redpinesignals.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 523b724a
......@@ -166,6 +166,9 @@ static int rsi_usb_reg_read(struct usb_device *usbdev,
if (!buf)
return status;
if (len > RSI_USB_CTRL_BUF_SIZE)
return -EINVAL;
status = usb_control_msg(usbdev,
usb_rcvctrlpipe(usbdev, 0),
USB_VENDOR_REGISTER_READ,
......@@ -208,6 +211,9 @@ static int rsi_usb_reg_write(struct usb_device *usbdev,
if (!usb_reg_buf)
return status;
if (len > RSI_USB_CTRL_BUF_SIZE)
return -EINVAL;
usb_reg_buf[0] = (value & 0x00ff);
usb_reg_buf[1] = (value & 0xff00) >> 8;
usb_reg_buf[2] = 0x0;
......
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