Commit 2b0ab727 authored by David S. Miller's avatar David S. Miller

Merge branch 'mlxsw-Couple-of-fixes'

Ido Schimmel says:

====================
mlxsw: Couple of fixes

First patch makes sure mlxsw does not ignore user requests to delete FDB
entries that were learned by the device.

Second patch fixes a use-after-free that can be triggered by requesting
a reload via devlink when the previous reload failed.

Please consider both patches for stable. They apply cleanly to both
4.18.y and 4.19.y.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 6e29464b a22712a9
......@@ -943,8 +943,8 @@ static int mlxsw_devlink_core_bus_device_reload(struct devlink *devlink,
mlxsw_core->bus,
mlxsw_core->bus_priv, true,
devlink);
if (err)
mlxsw_core->reload_fail = true;
mlxsw_core->reload_fail = !!err;
return err;
}
......@@ -1083,8 +1083,15 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
{
struct devlink *devlink = priv_to_devlink(mlxsw_core);
if (mlxsw_core->reload_fail)
goto reload_fail;
if (mlxsw_core->reload_fail) {
if (!reload)
/* Only the parts that were not de-initialized in the
* failed reload attempt need to be de-initialized.
*/
goto reload_fail_deinit;
else
return;
}
if (mlxsw_core->driver->fini)
mlxsw_core->driver->fini(mlxsw_core);
......@@ -1098,9 +1105,12 @@ void mlxsw_core_bus_device_unregister(struct mlxsw_core *mlxsw_core,
if (!reload)
devlink_resources_unregister(devlink, NULL);
mlxsw_core->bus->fini(mlxsw_core->bus_priv);
if (reload)
return;
reload_fail:
reload_fail_deinit:
devlink_unregister(devlink);
devlink_resources_unregister(devlink, NULL);
devlink_free(devlink);
}
EXPORT_SYMBOL(mlxsw_core_bus_device_unregister);
......
......@@ -2661,8 +2661,6 @@ static void mlxsw_sp_switchdev_bridge_fdb_event_work(struct work_struct *work)
break;
case SWITCHDEV_FDB_DEL_TO_DEVICE:
fdb_info = &switchdev_work->fdb_info;
if (!fdb_info->added_by_user)
break;
mlxsw_sp_port_fdb_set(mlxsw_sp_port, fdb_info, false);
break;
case SWITCHDEV_FDB_ADD_TO_BRIDGE: /* fall through */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment