lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250621-dwc3-fix-gadget-mtp-v1-3-a45e6def71bb@leica-geosystems.com>
Date: Sat, 21 Jun 2025 21:07:16 +0200
From: Johannes Schneider <johannes.schneider@...ca-geosystems.com>
To: Thinh Nguyen <Thinh.Nguyen@...opsys.com>, 
 Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Pengutronix Kernel Team <kernel@...gutronix.de>, 
 linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org, 
 bsp-development.geo@...ca-geosystems.com, 
 Johannes Schneider <johannes.schneider@...ca-geosystems.com>
Subject: [PATCH 3/3] usb: dwc3: gadget: Simplify logic in
 dwc3_needs_extra_trb()

The existing logic in dwc3_needs_extra_trb() checks multiple conditions
in a compound expression to determine whether an extra TRB is needed,
either for a ZLP or to handle short OUT transfers.

This commit simplifies the logic without changing behavior:
- Returns false early for isochronous endpoints
- Separates the conditions for IN vs OUT transfers
- Makes intent and flow easier to read and reason about

No functional changes intended.

Signed-off-by: Johannes Schneider <johannes.schneider@...ca-geosystems.com>
---
 drivers/usb/dwc3/gadget.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
index a4a2bf273f943fa112f49979297023a732e0af2e..32d0fb090f4c2ffab61ae6eee29a02efd32ed032 100644
--- a/drivers/usb/dwc3/gadget.c
+++ b/drivers/usb/dwc3/gadget.c
@@ -1420,12 +1420,13 @@ static bool dwc3_needs_extra_trb(struct dwc3_ep *dep, struct dwc3_request *req)
 	unsigned int maxp = usb_endpoint_maxp(dep->endpoint.desc);
 	unsigned int rem = req->request.length % maxp;
 
-	if ((req->request.length && req->request.zero && !rem &&
-			!usb_endpoint_xfer_isoc(dep->endpoint.desc)) ||
-			(!req->direction && rem))
-		return true;
+	if (usb_endpoint_xfer_isoc(dep->endpoint.desc))
+		return false;
+
+	if (!req->direction) /* OUT transfers */
+		return rem != 0;
 
-	return false;
+	return rem == 0;
 }
 
 /**

-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ