mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/7] usb: gadget: Fix net_device lifecycles and configfs races
@ 2026-03-20  8:54 Kuen-Han Tsai
  2026-03-20  8:54 ` [PATCH 1/7] usb: gadget: f_subset: Fix unbalanced refcnt in geth_free Kuen-Han Tsai
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Kuen-Han Tsai @ 2026-03-20  8:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Kyungmin Park, Felipe Balbi, David Lechner
  Cc: linux-usb, linux-kernel, Kuen-Han Tsai, stable

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>


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

end of thread, other threads:[~2026-03-20  8:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-20  8:54 [PATCH 0/7] usb: gadget: Fix net_device lifecycles and configfs races Kuen-Han Tsai
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

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®