]> git.baikalelectronics.ru Git - kernel.git/commit
mlxsw: spectrum: Fix use-after-free of split/unsplit/type_set in case reload fails
authorJiri Pirko <jiri@mellanox.com>
Thu, 21 May 2020 12:11:44 +0000 (15:11 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 22 May 2020 23:08:14 +0000 (16:08 -0700)
commit203897f7218654382fec9b095a0b775514c30609
tree605361b0e9f273e1eea08b80644a631665c27c34
parente21506e31e692790af74ffd913c1e704536342b4
mlxsw: spectrum: Fix use-after-free of split/unsplit/type_set in case reload fails

In case of reload fail, the mlxsw_sp->ports contains a pointer to a
freed memory (either by reload_down() or reload_up() error path).
Fix this by initializing the pointer to NULL and checking it before
dereferencing in split/unsplit/type_set callpaths.

Fixes: 965f7a2a41d2 ("mlxsw: core: Add support for reload")
Reported-by: Danielle Ratson <danieller@mellanox.com>
Signed-off-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/spectrum.c
drivers/net/ethernet/mellanox/mlxsw/switchx2.c