From: Kuen-Han Tsai <khtsai@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Kuen-Han Tsai <khtsai@google.com>
Subject: [PATCH 0/2] usb: gadget: Auto-cleanup usb_request in f_loopback, f_tcm
Date: Thu, 30 Oct 2025 23:14:18 +0800 [thread overview]
Message-ID: <20251030-auto-cleanup-v1-0-db30584fadfd@google.com> (raw)
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>
next reply other threads:[~2025-10-30 15:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-30 15:14 Kuen-Han Tsai [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251030-auto-cleanup-v1-0-db30584fadfd@google.com \
--to=khtsai@google.com \
--cc=Thinh.Nguyen@synopsys.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox