]> git.baikalelectronics.ru Git - kernel.git/commit
mlxsw: spectrum_router: Fix error path in mlxsw_sp_vr_create
authorJiri Pirko <jiri@mellanox.com>
Tue, 13 Feb 2018 10:22:42 +0000 (11:22 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 13 Feb 2018 17:22:29 +0000 (12:22 -0500)
commitc538634c3364d3f80ef7011f135bde54b4280539
tree82204c267dbe44d87749a3d32f48bd0303da1bb4
parent6a434f9d390a36db5399d03e8e546bcc104e8f7b
mlxsw: spectrum_router: Fix error path in mlxsw_sp_vr_create

Since mlxsw_sp_fib_create() and mlxsw_sp_mr_table_create()
use ERR_PTR macro to propagate int err through return of a pointer,
the return value is not NULL in case of failure. So if one
of the calls fails, one of vr->fib4, vr->fib6 or vr->mr4_table
is not NULL and mlxsw_sp_vr_is_used wrongly assumes
that vr is in use which leads to crash like following one:

[ 1293.949291] BUG: unable to handle kernel NULL pointer dereference at 00000000000006c9
[ 1293.952729] IP: mlxsw_sp_mr_table_flush+0x15/0x70 [mlxsw_spectrum]

Fix this by using local variables to hold the pointers and set vr->*
only in case everything went fine.

Fixes: be12ab40b0bd ("mlxsw: spectrum_router: Refactor virtual router handling")
Fixes: 50cea183ce49 ("mlxsw: spectrum_router: Extend virtual routers with IPv6 support")
Fixes: 0e39ec02ea1b ("mlxsw: spectrum_router: Add multicast routes notification handling functionality")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c