mlxsw: core: Fix devlink unregister flow
authorShalom Toledo <shalomt@mellanox.com>
Mon, 29 Oct 2018 14:26:16 +0000 (14:26 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 30 Oct 2018 03:48:00 +0000 (20:48 -0700)
commita22712a962912faf257e857ab6857f56a93cfb34
tree1680c564da69cb043357209ad82c8a98b03c4a2d
parentad0b9d94182be8356978d220c82f9837cffeb7a9
mlxsw: core: Fix devlink unregister flow

After a failed reload, the driver is still registered to devlink, its
devlink instance is still allocated and the 'reload_fail' flag is set.
Then, in the next reload try, the driver's allocated devlink instance will
be freed without unregistering from devlink and its components (e.g,
resources). This scenario can cause a use-after-free if the user tries to
execute command via devlink user-space tool.

Fix by not freeing the devlink instance during reload (failed or not).

Fixes: 24cc68ad6c46 ("mlxsw: core: Add support for reload")
Signed-off-by: Shalom Toledo <shalomt@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/core.c