net: sparx5: skip ptp deinit if init was skipped
Subsystems (3)
PATCH 1/1 net: sparx5: skip ptp deinit if init was skipped
sparx5_ptp_init() returns early on the base lan969x variants because they do not have the SPX5_FEATURE_PTP flag. It also returns early when no "ptp" interrupt is described. Unbinding the driver then causes a NULL pointer dereference when cleaning up uninitialized tx_skbs queues:
Unable to handle kernel NULL pointer dereference at virtual address
0000000000000008
Call trace:
skb_queue_purge_reason+0x68/0x120 (P)
sparx5_ptp_deinit+0x64/0xc0
mchp_sparx5_remove+0x38/0x70
platform_remove+0x20/0x30
device_remove+0x4c/0x80Before per-port tx_skbs were added, a NULL dereference would have happened when calling ptp_clock_unregister() on the never-registered PTP clocks.
Fix by returning early in sparx5_ptp_deinit() if PTP is not used.
--- drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/ethernet/microchip/sparx5/sparx5_ptp.c +3 -0
@@ -673,6 +673,9 @@ void sparx5_ptp_deinit(struct sparx5 *sparx5)struct sparx5_port *port;int i; +if (!sparx5->ptp) +return ; +if (sparx5->ptp_irq >=0 ) {disable_irq (sparx5->ptp_irq); sparx5->ptp_irq = -ENXIO ;
Signature · 1 line
2.55.0
Hi Quentin,
Quoted 14 lines
sparx5_ptp_init()returns early on the base lan969x variants because they do not have theSPX5_FEATURE_PTPflag. It also returns early when no "ptp" interrupt is described. Unbinding the driver then causes a NULL pointer dereference when cleaning up uninitializedtx_skbsqueues:Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008 Call trace: skb_queue_purge_reason+0x68/0x120 (P) sparx5_ptp_deinit+0x64/0xc0 mchp_sparx5_remove+0x38/0x70 platform_remove+0x20/0x30 device_remove+0x4c/0x80
Quoted 7 lines
Before per-port
tx_skbswere added, a NULL dereference would have happened when callingptp_clock_unregister()on the never-registered PTP clocks.Fix by returning early in
sparx5_ptp_deinit()if PTP is not used.Fixes 0933bd04047c ("net: sparx5: Add support for ptp clocks")Signed-off-by Quentin Freimanis <[email protected]>
Thanks!
/Daniel
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 14 lines · On Sun, 27 Sep 2026 21:45:42 -0700 you wrote:
sparx5_ptp_init()returns early on the base lan969x variants because they do not have theSPX5_FEATURE_PTPflag. It also returns early when no "ptp" interrupt is described. Unbinding the driver then causes a NULL pointer dereference when cleaning up uninitializedtx_skbsqueues:Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008 Call trace: skb_queue_purge_reason+0x68/0x120 (P) sparx5_ptp_deinit+0x64/0xc0 mchp_sparx5_remove+0x38/0x70 platform_remove+0x20/0x30 device_remove+0x4c/0x80
Quoted 1 line
[...]
Here is the summary with links:
- [net] net: sparx5: skip ptp deinit if init was skipped
https://git.kernel.org/netdev/net/c/0d2c49915bc3
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html