Skip to content

Commit

Permalink
Merge branch 'mlxsw-Couple-of-fixes'
Browse files Browse the repository at this point in the history
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: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Oct 30, 2018
2 parents 6e29464 + a22712a commit 2b0ab72
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
24 changes: 17 additions & 7 deletions drivers/net/ethernet/mellanox/mlxsw/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand All @@ -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:

return;

reload_fail_deinit:
devlink_unregister(devlink);
devlink_resources_unregister(devlink, NULL);
devlink_free(devlink);
}
EXPORT_SYMBOL(mlxsw_core_bus_device_unregister);
Expand Down
2 changes: 0 additions & 2 deletions drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 2b0ab72

Please sign in to comment.