提交 f3717e3a 编写于 作者: V Vladimir Oltean 提交者: Zheng Zengkai

net: dsa: call teardown method on probe failure

stable inclusion
from stable-5.10.17
commit c930943a368336be15b909cc1d6c344eceb3bd5e
bugzilla: 48169

--------------------------------

commit 8fd54a73 upstream.

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: 5e3f847a ("net: dsa: Add teardown callback for drivers")
Signed-off-by: NVladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
Reviewed-by: NFlorian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20210204163351.2929670-1-vladimir.oltean@nxp.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 c509f47c
...@@ -462,20 +462,23 @@ static int dsa_switch_setup(struct dsa_switch *ds) ...@@ -462,20 +462,23 @@ static int dsa_switch_setup(struct dsa_switch *ds)
ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev); ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev);
if (!ds->slave_mii_bus) { if (!ds->slave_mii_bus) {
err = -ENOMEM; err = -ENOMEM;
goto unregister_notifier; goto teardown;
} }
dsa_slave_mii_bus_init(ds); dsa_slave_mii_bus_init(ds);
err = mdiobus_register(ds->slave_mii_bus); err = mdiobus_register(ds->slave_mii_bus);
if (err < 0) if (err < 0)
goto unregister_notifier; goto teardown;
} }
ds->setup = true; ds->setup = true;
return 0; return 0;
teardown:
if (ds->ops->teardown)
ds->ops->teardown(ds);
unregister_notifier: unregister_notifier:
dsa_switch_unregister_notifier(ds); dsa_switch_unregister_notifier(ds);
unregister_devlink_ports: unregister_devlink_ports:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册