Commit ca3df346 authored by Thinh Nguyen's avatar Thinh Nguyen Committed by Felipe Balbi
Browse files

usb: dwc3: gadget: Check MPS of the request length



When preparing for SG, not all the entries are prepared at once. When
resume, don't use the remaining request length to calculate for MPS
alignment. Use the entire request->length to do that.

Cc: stable@vger.kernel.org
Fixes: 5d187c04 ("usb: dwc3: gadget: Don't setup more than requested")
Signed-off-by: default avatarThinh Nguyen <Thinh.Nguyen@synopsys.com>
Signed-off-by: default avatarFelipe Balbi <balbi@kernel.org>
parent 5b35dd1a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1098,6 +1098,8 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
	struct scatterlist *s;
	int		i;
	unsigned int length = req->request.length;
	unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
	unsigned int rem = length % maxp;
	unsigned int remaining = req->request.num_mapped_sgs
		- req->num_queued_sgs;

@@ -1109,8 +1111,6 @@ static void dwc3_prepare_one_trb_sg(struct dwc3_ep *dep,
		length -= sg_dma_len(s);

	for_each_sg(sg, s, remaining, i) {
		unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
		unsigned int rem = length % maxp;
		unsigned int trb_length;
		unsigned int chain = true;