usb: gadget: Auto-cleanup usb_request in f_loopback, f_tcm
Get series with b4
b4 am [email protected] change-id 20251029-auto-cleanup-e0240f2d7f2aVersions newest first
- v1 Latest2 patches 3 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | usb: gadget: f_tcm: Use auto-cleanup for usb_requestdrivers/ | +67 | 2 replies | |
| 2/2 | usb: gadget: f_loopback: Use auto-cleanup for usb_requestdrivers/ | +13 | 1 reply |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [PATCH 0/2] usb: gadget: Auto-cleanup usb_request in f_loopback, f_tcm
This series refactors f_loopback and f_tcm function drivers to use automatic, scope-based cleanup mechansim for usb_request objects.
Specific considerations in each driver:
- In f_loopback.c, the shared buffer between in_req and out_req is handled by nullifying in_req->buf before returning on usb_ep_queue failure. This ensures the buffer is only freed once by the out_req cleanup.
- In f_tcm.c, explicit nullification of request pointers in the f_uas structure on error is no longer necessary. The pointers are now only updated after all allocations within the respective functions (bot_prepare_reqs, uasp_alloc_stream_res, uasp_alloc_cmd) succeed. Existing cleanup functions handle any stale pointers if an error occurs before the structure is updated.
---
Kuen-Han Tsai (2):
usb: gadget: f_tcm: Use auto-cleanup for usb_request
usb: gadget: f_loopback: Use auto-cleanup for usb_request
drivers/usb/gadget/function/f_loopback.c | 30 +++---- drivers/usb/gadget/function/f_tcm.c | 141 +++++++++++++++---------------- 2 files changed, 80 insertions(+), 91 deletions(-)
---
base-commit: dcb6fa37fd7bc9c3d2b066329b0d27dedf8becaa
change-id: 20251029-auto-cleanup-e0240f2d7f2a
Best regards,
Signature · 1 line
Kuen-Han Tsai <[email protected]>