]> git.ipfire.org Git - thirdparty/linux.git/commit
net: dsa: mv88e6xxx: clean up PTP clock during setup failure
authorRussell King (Oracle) <rmk+kernel@armlinux.org.uk>
Mon, 15 Sep 2025 12:13:06 +0000 (13:13 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 16 Sep 2025 23:32:43 +0000 (16:32 -0700)
commitc94ef36ec9d1093e676c81a1ed415e63dffb0046
treee45329eb9e49404816a4c13fe9ca654986440327
parent3ea308da69b1a0848828e95eb5d514873f3a5249
net: dsa: mv88e6xxx: clean up PTP clock during setup failure

If an error occurs during mv88e6xxx_setup() and the PTP clock has been
registered, the clock will not be unregistered as mv88e6xxx_ptp_free()
will not be called. mv88e6xxx_hwtstamp_free() also is not called.

As mv88e6xxx_ptp_free() can cope with being called without a successful
call to mv88e6xxx_ptp_setup(), and mv88e6xxx_hwtstamp_free() is empty,
add both these *_free() calls to the error cleanup paths in
mv88e6xxx_setup().

Moreover, mv88e6xxx_teardown() should teardown setup done in
mv88e6xxx_setup() - see dsa_switch_setup(). However, instead *_free()
are called from mv88e6xxx_remove() function that is only called when a
device is unbound, which omits cleanup should a failure occur later in
dsa_switch_setup(). Move the *_free() calls from mv88e6xxx_remove() to
mv88e6xxx_teardown().

Note that mv88e6xxx_ptp_setup() must be called holding the reg_lock,
but mv88e6xxx_ptp_free() must never be. This is especially true after
commit "ptp: rework ptp_clock_unregister() to disable events". This
patch does not change this, but adds a comment to that effect.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Link: https://patch.msgid.link/E1uy84w-00000005Spi-46iF@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/mv88e6xxx/chip.c
drivers/net/dsa/mv88e6xxx/ptp.c