]> www.infradead.org Git - users/hch/misc.git/commitdiff
net: stmmac: fix PTP error cleanup in __stmmac_open()
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Thu, 11 Sep 2025 11:09:47 +0000 (12:09 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sun, 14 Sep 2025 19:01:00 +0000 (12:01 -0700)
The cleanup function for stmmac_setup_ptp() is stmmac_release_ptp()
which entirely undoes the effects of stmmac_setup_ptp() by
unregistering the PTP device and then stopping the PTP clock,
whereas stmmac_hw_teardown() will only stop the PTP clock while
leaving the PTP device registered.

This can lead to a kernel oops - if __stmmac_open() fails after
registering the PTP clock, the PTP device will remain registered,
and if the module is removed, subsequent PTP device accesses will
lead to a kernel oops.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

index 5d76cf7957abd868a75184e79cd4d49c1adcc7bb..167405aac5b885a7510a8de636af370c400850f6 100644 (file)
@@ -4032,7 +4032,7 @@ irq_error:
        for (chan = 0; chan < priv->plat->tx_queues_to_use; chan++)
                hrtimer_cancel(&priv->dma_conf.tx_queue[chan].txtimer);
 
-       stmmac_hw_teardown(dev);
+       stmmac_release_ptp(priv);
 init_error:
        phylink_disconnect_phy(priv->phylink);
 init_phy_error: