staging: dwc2: validate urb->actual_length for OUT endpoints

In dwc2_assign_and_init_hc(), validate urb->actual_length for OUT
endpoints before using the value. This fix is from the Synopsys
vendor driver.

Signed-off-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Paul Zimmerman 2013-09-23 14:23:33 -07:00 committed by Greg Kroah-Hartman
parent a4ec93d8b4
commit 8418108634
1 changed files with 4 additions and 0 deletions

View File

@ -780,6 +780,10 @@ static void dwc2_assign_and_init_hc(struct dwc2_hsotg *hsotg,
chan->data_pid_start = qh->data_toggle; chan->data_pid_start = qh->data_toggle;
chan->multi_count = 1; chan->multi_count = 1;
if ((urb->actual_length < 0 || urb->actual_length > urb->length) &&
!dwc2_hcd_is_pipe_in(&urb->pipe_info))
urb->actual_length = urb->length;
if (hsotg->core_params->dma_enable > 0) { if (hsotg->core_params->dma_enable > 0) {
chan->xfer_dma = urb->dma + urb->actual_length; chan->xfer_dma = urb->dma + urb->actual_length;