Skip to content

Commit

Permalink
Merge pull request #3371 from jason77-wang/rpi-5.3.y
Browse files Browse the repository at this point in the history
dwc_otg: checking the urb->transfer_buffer too early (#3332)
  • Loading branch information
P33M authored Dec 6, 2019
2 parents 216c323 + 06c1d85 commit 3082ba0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions drivers/usb/host/dwc_otg/dwc_otg_hcd_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,10 +821,6 @@ static int dwc_otg_urb_enqueue(struct usb_hcd *hcd,
dump_urb_info(urb, "dwc_otg_urb_enqueue");
}
#endif

if (!urb->transfer_buffer && urb->transfer_buffer_length)
return -EINVAL;

if ((usb_pipetype(urb->pipe) == PIPE_ISOCHRONOUS)
|| (usb_pipetype(urb->pipe) == PIPE_INTERRUPT)) {
if (!dwc_otg_hcd_is_bandwidth_allocated
Expand Down Expand Up @@ -881,6 +877,13 @@ static int dwc_otg_urb_enqueue(struct usb_hcd *hcd,
&urb->transfer_dma, buf);
}

if (!buf && urb->transfer_buffer_length) {
DWC_FREE(dwc_otg_urb);
DWC_ERROR("transfer_buffer is NULL in PIO mode or both "
"transfer_buffer and transfer_dma are NULL in DMA mode\n");
return -EINVAL;
}

if (!(urb->transfer_flags & URB_NO_INTERRUPT))
flags |= URB_GIVEBACK_ASAP;
if (urb->transfer_flags & URB_ZERO_PACKET)
Expand Down

0 comments on commit 3082ba0

Please sign in to comment.