mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kuen-Han Tsai <khtsai@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	 David Brownell <dbrownell@users.sourceforge.net>,
	Nam Cao <namcao@linutronix.de>,
	 Zack Rusin <zack.rusin@broadcom.com>,
	 Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
	Prashanth K <prashanth.k@oss.qualcomm.com>,
	 Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
	John Keeping <jkeeping@inmusicbrands.com>,
	 Roy Luo <royluo@google.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Kuen-Han Tsai <khtsai@google.com>,
	stable@kernel.org
Subject: [PATCH 0/6] usb: gadget: Refactor function drivers to use __free() cleanup
Date: Tue, 16 Sep 2025 16:21:31 +0800	[thread overview]
Message-ID: <20250916-ready-v1-0-4997bf277548@google.com> (raw)

Hello,

This patch series refactors the error-handling paths in the bind()
function for f_ncm, f_acm, f_ecm, and f_rndis drivers. 

The current, unified goto logic in these drivers is vulnerable to a null
pointer dereference. This is caused by the cleanup logic incorrectly
handling the stale usb_request pointer after a bind/unbind cycle. This
series fixes this issue by converting the drivers to use the modern
__free() scope-based cleanup mechanism.

Patches 1-2 are preparatory, adding the endpoint pointer to struct
usb_request and defining helpers for the __free() cleanup. The remaining
four patches use this new plumbing to refactor each driver.

Future work
-----------

1. Refactor usb_ep_free_request(), usb_ep_queue(), and usb_ep_dequeue()
   functions as the ep parameter becomes redudant.
2. Convert the remaining gadget function drivers to use the new __free()
   cleanup mechanism.

Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
---
Kuen-Han Tsai (6):
      usb: gadget: Store endpoint pointer in usb_request
      usb: gadget: Introduce free_usb_request helper
      usb: gadget: f_ncm: Refactor bind path to use __free()
      usb: gadget: f_acm: Refactor bind path to use __free()
      usb: gadget: f_ecm: Refactor bind path to use __free()
      usb: gadget: f_rndis: Refactor bind path to use __free()

 drivers/usb/gadget/function/f_acm.c   | 42 ++++++++---------
 drivers/usb/gadget/function/f_ecm.c   | 48 +++++++++-----------
 drivers/usb/gadget/function/f_ncm.c   | 78 ++++++++++++++------------------
 drivers/usb/gadget/function/f_rndis.c | 85 +++++++++++++++--------------------
 drivers/usb/gadget/udc/core.c         |  3 ++
 include/linux/usb/gadget.h            | 25 +++++++++++
 6 files changed, 135 insertions(+), 146 deletions(-)
---
base-commit: 1b237f190eb3d36f52dffe07a40b5eb210280e00
change-id: 20250916-ready-70b1c55d14b6

Best regards,
-- 
Kuen-Han Tsai <khtsai@google.com>


             reply	other threads:[~2025-09-16  8:21 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-16  8:21 Kuen-Han Tsai [this message]
2025-09-16  8:21 ` [PATCH 1/6] usb: gadget: Store endpoint pointer in usb_request Kuen-Han Tsai
2025-09-16  8:21 ` [PATCH 2/6] usb: gadget: Introduce free_usb_request helper Kuen-Han Tsai
2025-09-16  8:21 ` [PATCH 3/6] usb: gadget: f_ncm: Refactor bind path to use __free() Kuen-Han Tsai
2025-09-16  8:21 ` [PATCH 4/6] usb: gadget: f_acm: " Kuen-Han Tsai
2025-09-16  8:21 ` [PATCH 5/6] usb: gadget: f_ecm: " Kuen-Han Tsai
2025-09-16  8:21 ` [PATCH 6/6] usb: gadget: f_rndis: " Kuen-Han Tsai

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=20250916-ready-v1-0-4997bf277548@google.com \
    --to=khtsai@google.com \
    --cc=Thinh.Nguyen@synopsys.com \
    --cc=dbrownell@users.sourceforge.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jkeeping@inmusicbrands.com \
    --cc=krzysztof.kozlowski@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=namcao@linutronix.de \
    --cc=prashanth.k@oss.qualcomm.com \
    --cc=royluo@google.com \
    --cc=stable@kernel.org \
    --cc=zack.rusin@broadcom.com \
    /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

all inboxes | Powered by JetHome®