From: Kuen-Han Tsai <khtsai@google.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Kyungmin Park <kyungmin.park@samsung.com>,
Felipe Balbi <balbi@kernel.org>,
David Lechner <david@lechnology.com>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Kuen-Han Tsai <khtsai@google.com>,
stable@vger.kernel.org
Subject: [PATCH 0/7] usb: gadget: Fix net_device lifecycles and configfs races
Date: Fri, 20 Mar 2026 16:54:43 +0800 [thread overview]
Message-ID: <20260320-usb-net-lifecycle-v1-0-4886b578161b@google.com> (raw)
Hi all,
This patch series addresses dangling sysfs symlink issues across the
remaining USB gadget network functions (f_ecm, f_eem, f_subset, and
f_rndis). It also includes configfs concurrency and reference-counting
bug fixes identified during the investigation.
Commit ec35c1969650 ("usb: gadget: f_ncm: Fix net_device lifecycle
with device_move") introduced an architectural fix for f_ncm to resolve
an issue where unbinding the function resulted in the net_device
surviving the destruction of its gadget parent device. This lifecycle
mismatch leaves dangling sysfs symlinks:
console:/ # ls -l /sys/class/net/usb0
lrwxrwxrwx ... /sys/class/net/usb0 ->
/sys/devices/platform/.../gadget.0/net/usb0
console:/ # ls -l /sys/devices/platform/.../gadget.0/net/usb0
ls: .../gadget.0/net/usb0: No such file or directory
This series applies the same device_move() pattern to the rest of the
USB network functions. Temporarily moving the net_device to
/sys/devices/virtual during unbind, and re-parenting it back to the new
gadget device during bind, restores proper sysfs topology without
leaking references or breaking legacy composite drivers (like multi.c).
To ensure safe teardown and avoid regressing legacy composite drivers
that manually pre-register net_devices, the bound and borrowed_net
flags now strictly indicate if the device was shared and
pre-registered during the legacy driver's bind phase.
Patch Summary:
- Patches 1-2: Fix an unbalanced reference count in f_subset and add a
missing configfs mutex lock for RNDIS options.
- Patch 3: Add comprehensive kernel-doc descriptions for struct
f_ncm_opts to match the standard applied to the other functions.
- Patches 4-7: Implement the device_move() lifecycle fix consistently
across f_ecm, f_eem, f_subset, and f_rndis.
Signed-off-by: Kuen-Han Tsai <khtsai@google.com>
---
Kuen-Han Tsai (7):
usb: gadget: f_subset: Fix unbalanced refcnt in geth_free
usb: gadget: f_rndis: Protect RNDIS options with mutex
usb: gadget: u_ncm: Add kernel-doc comments for struct f_ncm_opts
usb: gadget: f_ecm: Fix net_device lifecycle with device_move
usb: gadget: f_eem: Fix net_device lifecycle with device_move
usb: gadget: f_subset: Fix net_device lifecycle with device_move
usb: gadget: f_rndis: Fix net_device lifecycle with device_move
drivers/usb/gadget/function/f_ecm.c | 37 +++++++++++++-------
drivers/usb/gadget/function/f_eem.c | 59 ++++++++++++++++---------------
drivers/usb/gadget/function/f_rndis.c | 51 ++++++++++++++++-----------
drivers/usb/gadget/function/f_subset.c | 63 +++++++++++++++++++---------------
drivers/usb/gadget/function/u_ecm.h | 21 ++++++++----
drivers/usb/gadget/function/u_eem.h | 21 ++++++++----
drivers/usb/gadget/function/u_gether.h | 22 ++++++++----
drivers/usb/gadget/function/u_ncm.h | 21 ++++++++----
drivers/usb/gadget/function/u_rndis.h | 31 ++++++++++++-----
9 files changed, 204 insertions(+), 122 deletions(-)
---
base-commit: f50200dd44125e445a6164e88c217472fa79cdbc
change-id: 20260320-usb-net-lifecycle-cd5911d7e013
Best regards,
--
Kuen-Han Tsai <khtsai@google.com>
next reply other threads:[~2026-03-20 8:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-20 8:54 Kuen-Han Tsai [this message]
2026-03-20 8:54 ` [PATCH 1/7] usb: gadget: f_subset: Fix unbalanced refcnt in geth_free Kuen-Han Tsai
2026-03-20 8:54 ` [PATCH 2/7] usb: gadget: f_rndis: Protect RNDIS options with mutex Kuen-Han Tsai
2026-03-20 8:54 ` [PATCH 3/7] usb: gadget: u_ncm: Add kernel-doc comments for struct f_ncm_opts Kuen-Han Tsai
2026-03-20 8:54 ` [PATCH 4/7] usb: gadget: f_ecm: Fix net_device lifecycle with device_move Kuen-Han Tsai
2026-03-20 8:54 ` [PATCH 5/7] usb: gadget: f_eem: " Kuen-Han Tsai
2026-03-20 8:54 ` [PATCH 6/7] usb: gadget: f_subset: " Kuen-Han Tsai
2026-03-20 8:54 ` [PATCH 7/7] 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=20260320-usb-net-lifecycle-v1-0-4886b578161b@google.com \
--to=khtsai@google.com \
--cc=balbi@kernel.org \
--cc=david@lechnology.com \
--cc=gregkh@linuxfoundation.org \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@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
all inboxes | Powered by JetHome®