0145-dcw_otg-trim-xfer-length-when-buffer-larger-than-all.patch 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. From 2407b0b1342fbe40d1c25a879590544405a07a11 Mon Sep 17 00:00:00 2001
  2. From: popcornmix <popcornmix@gmail.com>
  3. Date: Fri, 12 Feb 2016 14:50:25 +0000
  4. Subject: [PATCH] dcw_otg: trim xfer length when buffer larger than allocated
  5. size is received
  6. ---
  7. drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c | 11 +++++++++++
  8. 1 file changed, 11 insertions(+)
  9. --- a/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c
  10. +++ b/drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c
  11. @@ -737,6 +737,11 @@ static int update_urb_state_xfer_comp(dw
  12. DWC_OTG_HC_XFER_COMPLETE,
  13. &short_read);
  14. + if (urb->actual_length + xfer_length > urb->length) {
  15. + DWC_WARN("%s(): trimming xfer length\n", __func__);
  16. + xfer_length = urb->length - urb->actual_length;
  17. + }
  18. +
  19. /* non DWORD-aligned buffer case handling. */
  20. if (hc->align_buff && xfer_length && hc->ep_is_in) {
  21. dwc_memcpy(urb->buf + urb->actual_length, hc->qh->dw_align_buf,
  22. @@ -1423,6 +1428,12 @@ static void update_urb_state_xfer_intr(d
  23. {
  24. uint32_t bytes_transferred = get_actual_xfer_length(hc, hc_regs, qtd,
  25. halt_status, NULL);
  26. +
  27. + if (urb->actual_length + bytes_transferred > urb->length) {
  28. + DWC_WARN("%s(): trimming xfer length\n", __func__);
  29. + bytes_transferred = urb->length - urb->actual_length;
  30. + }
  31. +
  32. /* non DWORD-aligned buffer case handling. */
  33. if (hc->align_buff && bytes_transferred && hc->ep_is_in) {
  34. dwc_memcpy(urb->buf + urb->actual_length, hc->qh->dw_align_buf,