public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] usb: gadget: Auto-cleanup usb_request in f_loopback, f_tcm
@ 2025-10-30 15:14 Kuen-Han Tsai
  2025-10-30 15:14 ` [PATCH 1/2] usb: gadget: f_tcm: Use auto-cleanup for usb_request Kuen-Han Tsai
  2025-10-30 15:14 ` [PATCH 2/2] usb: gadget: f_loopback: " Kuen-Han Tsai
  0 siblings, 2 replies; 6+ messages in thread
From: Kuen-Han Tsai @ 2025-10-30 15:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Thinh Nguyen; +Cc: linux-usb, linux-kernel, Kuen-Han Tsai

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.

Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
---
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,
-- 
Kuen-Han Tsai <khtsai@google.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-11-03  9:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-30 15:14 [PATCH 0/2] usb: gadget: Auto-cleanup usb_request in f_loopback, f_tcm Kuen-Han Tsai
2025-10-30 15:14 ` [PATCH 1/2] usb: gadget: f_tcm: Use auto-cleanup for usb_request Kuen-Han Tsai
2025-10-30 15:33   ` Greg Kroah-Hartman
2025-11-03  9:54     ` Kuen-Han Tsai
2025-10-30 15:14 ` [PATCH 2/2] usb: gadget: f_loopback: " Kuen-Han Tsai
2025-10-30 15:34   ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox