]> git.baikalelectronics.ru Git - kernel.git/commit
net: dsa: mt7530: fix kernel bug in mdiobus_free() when unbinding
authorVladimir Oltean <vladimir.oltean@nxp.com>
Mon, 7 Feb 2022 16:15:52 +0000 (18:15 +0200)
committerJakub Kicinski <kuba@kernel.org>
Wed, 9 Feb 2022 04:30:35 +0000 (20:30 -0800)
commit902c4a2b95e54a09c76c4a00d8fc2cf4ea42d16d
tree8d6fca6d198f310259ccbe73a1879676ef5cfa1d
parentec5251fb57ad279b2a1299490e8c492afa8fc49f
net: dsa: mt7530: fix kernel bug in mdiobus_free() when unbinding

Nobody in this driver calls mdiobus_unregister(), which is necessary if
mdiobus_register() completes successfully. So if the devres callbacks
that free the mdiobus get invoked (this is the case when unbinding the
driver), mdiobus_free() will BUG if the mdiobus is still registered,
which it is.

My speculation is that this is due to the fact that prior to commit
50298441a391 ("net: phy: don't abuse devres in devm_mdiobus_register()")
from June 2020, _devm_mdiobus_free() used to call mdiobus_unregister().
But at the time that the mt7530 support was introduced in May 2021, the
API was already changed. It's therefore likely that the blamed patch was
developed on an older tree, and incorrectly adapted to net-next. This
makes the Fixes: tag correct.

Fix the problem by using the devres variant of mdiobus_register.

Fixes: f3dedaccd56e ("net: dsa: mt7530: add interrupt support")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/mt7530.c