rockchip64: fix USB gadget NULL pointer crash in eth_get_drvinfo (6.18 + 7.0)#9608
rockchip64: fix USB gadget NULL pointer crash in eth_get_drvinfo (6.18 + 7.0)#9608rubycomm wants to merge 1 commit intoarmbian:mainfrom
Conversation
…8 + 7.0) Port Ondrej Jirman's (megi) dangling pointer fix from sunxi to rockchip64. Without this patch, udev querying ethtool on the USB gadget ethernet interface during DWC3 bind/unbind cycles can hit a NULL pointer dereference in eth_get_drvinfo(), causing intermittent kernel panics at boot. The f_ncm.c hunks from the original patch are excluded because mainline already handles NCM gadget lifecycle properly via the gether_attach_gadget()/gether_detach_gadget() API. Tested on NanoPi Zero2 (RK3528) with 8 consecutive reboot cycles and zero crashes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThese patches eliminate stale gadget pointers persisting in netdev private data across gadget destroy/recreate cycles. They synchronize gadget pointer updates during bind via Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
eth_get_drvinfo()when udev queries ethtool on a USB gadget ethernet interface during DWC3 bind/unbind cyclescurrent(6.18) andedge(7.0) kernel branchesProblem
When USB gadget ethernet (NCM/ECM/RNDIS) is configured, the DWC3 controller may destroy and re-create the gadget during role switching. If udev probes the network interface via ethtool during this window,
eth_get_drvinfo()dereferences a NULLdev->gadgetpointer, causing a kernel panic:This crash is intermittent — it depends on timing between udev and the gadget bind/unbind cycle.
Fix
The patch (originally by Ondrej Jirman / megi, already applied in sunxi):
dev->gadgetineth_get_drvinfo()SET_NETDEV_DEV()parenting that creates stale references after gadget destructionNote: The
f_ncm.chunks from the original patch are excluded because mainline already handles NCM gadget lifecycle viagether_attach_gadget()/gether_detach_gadget().Test plan
git apply --check)ethtool -i usb0returns without crash6.18.20-current-rockchip64Summary by CodeRabbit