diff mbox series

usb: dwc2: Fix in ISOC request length checking

Message ID d96e104b1913f11f0d3763f3badb0aaf9b3dae77.1578925847.git.hminas@synopsys.com (mailing list archive)
State Superseded
Headers show
Series usb: dwc2: Fix in ISOC request length checking | expand

Commit Message

Minas Harutyunyan Jan. 13, 2020, 2:32 p.m. UTC
Move ISOC request length cheking from dwc2_hsotg_start_req() function to
dwc2_hsotg_ep_queue().

Fixes: 4fca54aa58293 "usb: gadget: s3c-hsotg: add multi count support"
Robert Baldyga <r.baldyga@samsung.com>

Signed-off-by: Minas Harutyunyan <hminas@synopsys.com>
---
 drivers/usb/dwc2/gadget.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Sergei Shtylyov Jan. 14, 2020, 9:36 a.m. UTC | #1
Hello!

On 13.01.2020 17:32, Minas Harutyunyan wrote:

> Move ISOC request length cheking from dwc2_hsotg_start_req() function to

    Checking. :-)

> dwc2_hsotg_ep_queue().
> 
> Fixes: 4fca54aa58293 "usb: gadget: s3c-hsotg: add multi count support"

    You also need () around the patch summary: ("<summary>")...

> Robert Baldyga <r.baldyga@samsung.com>

    What's that?

> 

    All tags should be listed without new lines in between.

> Signed-off-by: Minas Harutyunyan <hmina
[...]

MBR, Sergei
diff mbox series

Patch

diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 88f7d6d4ff2d..7b40cf5bdc2f 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -1083,11 +1083,6 @@  static void dwc2_hsotg_start_req(struct dwc2_hsotg *hsotg,
 	else
 		packets = 1;	/* send one packet if length is zero. */
 
-	if (hs_ep->isochronous && length > (hs_ep->mc * hs_ep->ep.maxpacket)) {
-		dev_err(hsotg->dev, "req length > maxpacket*mc\n");
-		return;
-	}
-
 	if (dir_in && index != 0)
 		if (hs_ep->isochronous)
 			epsize = DXEPTSIZ_MC(packets);
@@ -1391,6 +1386,13 @@  static int dwc2_hsotg_ep_queue(struct usb_ep *ep, struct usb_request *req,
 	req->actual = 0;
 	req->status = -EINPROGRESS;
 
+	/* Don't queue ISOC request if length greater than mps*mc */
+	if (hs_ep->isochronous &&
+	    req->length > (hs_ep->mc * hs_ep->ep.maxpacket)) {
+		dev_err(hs->dev, "req length > maxpacket*mc\n");
+		return -EINVAL;
+	}
+
 	/* In DDMA mode for ISOC's don't queue request if length greater
 	 * than descriptor limits.
 	 */