Skip to content

Commit 548bb23

Browse files
P33Mpopcornmix
authored andcommitted
usb: dwc2: limit "maximum packet size" for split-IN transfers
dwc2_hc_start_transfer() overwrites hc->xfer_len for split-IN transfers. Drivers may not allocate buffers that are multiples of the endpoint max packet size, which may cause buffer overruns in the last transfer. The hardware needs HCTSIZ to be set to a multiple of HCCHAR.MPS, so trim chan->max_packet in dwc2_assign_and_init_hc(). Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
1 parent 628229a commit 548bb23

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

drivers/usb/dwc2/hcd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2646,6 +2646,10 @@ static int dwc2_assign_and_init_hc(struct dwc2_hsotg *hsotg, struct dwc2_qh *qh)
26462646
else
26472647
chan->do_split = 0;
26482648

2649+
/* Limit split IN transfers to the remaining buffer space */
2650+
if (qh->do_split && chan->ep_is_in)
2651+
chan->max_packet = min_t(u32, chan->max_packet, chan->xfer_len);
2652+
26492653
/* Set the transfer attributes */
26502654
dwc2_hc_init_xfer(hsotg, chan, qtd);
26512655

0 commit comments

Comments
 (0)