diff options
author | Vladimir Oltean <vladimir.oltean@nxp.com> | 2021-02-04 17:33:51 +0100 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2021-02-05 05:22:00 +0100 |
commit | 8fd54a73b7cda11548154451bdb4bde6d8ff74c7 (patch) | |
tree | acfaafe203d44286c9be0a1c86e0b1177e4528ce /net/dsa | |
parent | net: enetc: initialize the RFS and RSS memories (diff) | |
download | linux-8fd54a73b7cda11548154451bdb4bde6d8ff74c7.tar.xz linux-8fd54a73b7cda11548154451bdb4bde6d8ff74c7.zip |
net: dsa: call teardown method on probe failure
Since teardown is supposed to undo the effects of the setup method, it
should be called in the error path for dsa_switch_setup, not just in
dsa_switch_teardown.
Fixes: 5e3f847a02aa ("net: dsa: Add teardown callback for drivers")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20210204163351.2929670-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/dsa')
-rw-r--r-- | net/dsa/dsa2.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c index a47e0f9b20d0..a04fd637b4cd 100644 --- a/net/dsa/dsa2.c +++ b/net/dsa/dsa2.c @@ -462,20 +462,23 @@ static int dsa_switch_setup(struct dsa_switch *ds) ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev); if (!ds->slave_mii_bus) { err = -ENOMEM; - goto unregister_notifier; + goto teardown; } dsa_slave_mii_bus_init(ds); err = mdiobus_register(ds->slave_mii_bus); if (err < 0) - goto unregister_notifier; + goto teardown; } ds->setup = true; return 0; +teardown: + if (ds->ops->teardown) + ds->ops->teardown(ds); unregister_notifier: dsa_switch_unregister_notifier(ds); unregister_devlink_ports: |