]> 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)
commit422cf4c8bbcf74edd623a2420678ef10da0e6538
tree605361b0e9f273e1eea08b80644a631665c27c34
parentf6ef4e7def783697722efcf3a87e0d7b7e60c8cb
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: 5c3febf4a390 ("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