From: Val Packett <val@packett.cool>
To: Kuen-Han Tsai <khtsai@google.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Felipe Balbi <balbi@ti.com>,
Kyungmin Park <kyungmin.park@samsung.com>
Cc: David Heidelberg <david@ixit.cz>,
Ernest Van Hoecke <ernest.vanhoecke@toradex.com>,
Jon Hunter <jonathanh@nvidia.com>,
LI Qingwu <Qing-wu.Li@leica-geosystems.com.cn>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@kernel.org
Subject: Re: [PATCH v2 7/7] usb: gadget: f_ncm: Fix net_device lifecycle with device_move
Date: Sun, 15 Mar 2026 02:21:30 -0300 [thread overview]
Message-ID: <10890524-cf83-4a71-b879-93e2b2cc1fcc@packett.cool> (raw)
In-Reply-To: <20260309-f-ncm-revert-v2-7-ea2afbc7d9b2@google.com>
Hi,
On 3/9/26 9:04 AM, Kuen-Han Tsai wrote:
> The network device outlived its parent gadget device during
> disconnection, resulting in dangling sysfs links and null pointer
> dereference problems.
>
> A prior attempt to solve this by removing SET_NETDEV_DEV entirely [1]
> was reverted due to power management ordering concerns and a NO-CARRIER
> regression.
>
> A subsequent attempt to defer net_device allocation to bind [2] broke
> 1:1 mapping between function instance and network device, making it
> impossible for configfs to report the resolved interface name. This
> results in a regression where the DHCP server fails on pmOS.
>
> [..]
I just saw that this was the last commit touching u_ether while
debugging… the DHCP server failing on pmOS. (In the initrd, even).
Specifically, udev calling ethtool_get_drvinfo and eth_get_drvinfo
dereferencing an unset dev->gadget:
[ 7.528277] [pmOS-rd]: Setting up USB gadget through configfs
[ 7.539437] configfs-gadget.g1 gadget.0: HOST MAC 2a:a6:63:b7:92:23
[ 7.545914] configfs-gadget.g1 gadget.0: MAC 76:1d:2b:16:aa:25
[ 7.577888] [pmOS-rd]: Trying to start server with parameters: Server
IP addr: 172.16.42.1:67, client IP addr: 172.16.42.2, interface: usb0
[ 7.591522] [pmOS-rd]: Entering debug shell
[ 7.597590] Unable to handle kernel NULL pointer dereference at
virtual address 0000000000000080
[ 7.606670] Mem abort info:
[ 7.609571] ESR = 0x0000000096000004
[ 7.613462] EC = 0x25: DABT (current EL), IL = 32 bits
[ 7.618942] SET = 0, FnV = 0
[ 7.622105] EA = 0, S1PTW = 0
[ 7.625354] FSC = 0x04: level 0 translation fault
[ 7.630395] Data abort info:
[ 7.630398] ISV = 0, ISS = 0x00000004, ISS2 = 0x00000000
[ 7.630401] CM = 0, WnR = 0, TnD = 0, TagAccess = 0
[ 7.630404] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[ 7.630407] user pgtable: 4k pages, 48-bit VAs, pgdp=0000000107b18000
[ 7.630411] [0000000000000080] pgd=0000000000000000, p4d=0000000000000000
[ 7.630420] Internal error: Oops: 0000000096000004 [#1] SMP
[ 7.630425] Modules linked in: typec msm ubwc_config mdt_loader ocmem
rtc_pm8xxx drm_gpuvm drm_exec i2c_qcom_geni llcc_qcom gpi gpu_sched
drm_client_lib phy_qcom_snps_femto_v2 drm_display_helper cec
drm_dp_aux_bus icc_bwmon drm_kms_helper drm backlight ufs_qcom
phy_qcom_qmp_ufs icc_osm_l3 pmic_glink pdr_interface qcom_pdr_msg
qmi_helpers
[ 7.630486] CPU: 1 UID: 0 PID: 175 Comm: (udev-worker) Tainted: G
W 7.0.0-rc3-next-20260313-00118-gf4f287b6004a-dirty #59 PREEMPT(full)
[ 7.630493] Tainted: [W]=WARN
[ 7.630495] Hardware name: Motorola edge 30 (DT)
[ 7.630499] pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS
BTYPE=--)
[ 7.630503] pc : eth_get_drvinfo+0x50/0x90 <..snip..>
[ 7.630595] Call trace:
[ 7.630598] eth_get_drvinfo+0x50/0x90 (P)
[ 7.630608] ethtool_get_drvinfo+0x5c/0x1f0
[ 7.630617] __dev_ethtool+0xaec/0x1fe0
[ 7.630622] dev_ethtool+0x134/0x2e0
[ 7.630627] dev_ioctl+0x338/0x560
[ 7.630633] sock_do_ioctl+0xe0/0x128
[ 7.630642] sock_ioctl+0x2cc/0x3e0
[ 7.630647] __arm64_sys_ioctl+0xac/0x108
[ 7.630656] invoke_syscall.constprop.0+0x48/0x100
[ 7.630664] el0_svc_common.constprop.0+0x40/0xe8
[ 7.630670] do_el0_svc+0x24/0x38
[ 7.630676] el0_svc+0x34/0x180
[ 7.642931] [pmOS-rd]: /usr/bin/buffyboard
[ 7.644473] el0t_64_sync_handler+0xa0/0xe8
[ 7.644482] el0t_64_sync+0x17c/0x180
[ 7.644491] Code: 91094021 94134bd9 f9457680 d2800402 (f9404001)
[ 7.644495] ---[ end trace 0000000000000000 ]---
As a "workaround", this works:
--- a/drivers/usb/gadget/function/u_ether.c
+++ b/drivers/usb/gadget/function/u_ether.c
@@ -113,8 +113,14 @@
strscpy(p->driver, "g_ether", sizeof(p->driver));
strscpy(p->version, UETH__VERSION, sizeof(p->version));
- strscpy(p->fw_version, dev->gadget->name, sizeof(p->fw_version));
- strscpy(p->bus_info, dev_name(&dev->gadget->dev), sizeof(p->bus_info));
+ if (dev->gadget) {
+ strscpy(p->fw_version, dev->gadget->name, sizeof(p->fw_version));
+ strscpy(p->bus_info, dev_name(&dev->gadget->dev),
sizeof(p->bus_info));
+ } else {
+ pr_warn("%s: called with no gadget set\n", __func__);
+ strscpy(p->fw_version, "N/A", sizeof(p->fw_version));
+ strscpy(p->bus_info, "platform", sizeof(p->bus_info));
+ }
}
/* REVISIT can also support:
..or would that not be a workaround? The lifecycle of gadget being set
seems kinda decoupled from the lifecycle of the registration (??) And as
long as it's registered, the dev info can be queried (?)
Thanks,
~val
next prev parent reply other threads:[~2026-03-15 5:21 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 12:04 [PATCH v2 0/7] usb: gadget: " Kuen-Han Tsai
2026-03-09 12:04 ` [PATCH v2 1/7] Revert "usb: gadget: f_ncm: Fix atomic context locking issue" Kuen-Han Tsai
2026-03-09 12:04 ` [PATCH v2 2/7] Revert "usb: legacy: ncm: Fix NPE in gncm_bind" Kuen-Han Tsai
2026-03-09 12:04 ` [PATCH v2 3/7] Revert "usb: gadget: f_ncm: align net_device lifecycle with bind/unbind" Kuen-Han Tsai
2026-03-09 12:04 ` [PATCH v2 4/7] Revert "usb: gadget: u_ether: Add auto-cleanup helper for freeing net_device" Kuen-Han Tsai
2026-03-09 12:04 ` [PATCH v2 5/7] Revert "usb: gadget: u_ether: use <linux/hex.h> header file" Kuen-Han Tsai
2026-03-09 12:04 ` [PATCH v2 6/7] Revert "usb: gadget: u_ether: add gether_opts for config caching" Kuen-Han Tsai
2026-03-09 12:04 ` [PATCH v2 7/7] usb: gadget: f_ncm: Fix net_device lifecycle with device_move Kuen-Han Tsai
2026-03-15 5:21 ` Val Packett [this message]
2026-03-16 6:03 ` Kuen-Han Tsai
2026-03-13 12:40 ` [PATCH v2 0/7] usb: gadget: " Luca Weiss
2026-03-16 6:17 ` Kuen-Han Tsai
2026-03-16 6:35 ` Greg Kroah-Hartman
2026-03-16 6:47 ` 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=10890524-cf83-4a71-b879-93e2b2cc1fcc@packett.cool \
--to=val@packett.cool \
--cc=Qing-wu.Li@leica-geosystems.com.cn \
--cc=balbi@ti.com \
--cc=david@ixit.cz \
--cc=ernest.vanhoecke@toradex.com \
--cc=gregkh@linuxfoundation.org \
--cc=jonathanh@nvidia.com \
--cc=khtsai@google.com \
--cc=kyungmin.park@samsung.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@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®