]> git.baikalelectronics.ru Git - kernel.git/commit
mlxsw: spectrum_router: Fix handling of neighbour structure
authorJiri Pirko <jiri@mellanox.com>
Thu, 10 Nov 2016 11:31:04 +0000 (12:31 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 10 Nov 2016 18:02:15 +0000 (13:02 -0500)
commit90b97e36110f32dafb7c111db0281319bc4fe5aa
tree516ea68da5d5e948bf32aeb098a72e2042165470
parente49bb78b1004bc9b4d2506d424256061e20b1158
mlxsw: spectrum_router: Fix handling of neighbour structure

__neigh_create function works in a different way than assumed.
It passes "n" as a parameter to ndo_neigh_construct. But this "n" might
be destroyed right away before __neigh_create() returns in case there is
already another neighbour struct in the hashtable with the same dev and
primary key. That is not expected by mlxsw_sp_router_neigh_construct()
and the stored "n" points to freed memory, eventually leading to crash.

Fix this by doing tight 1:1 coupling between neighbour struct and
internal driver neigh_entry. That allows to narrow down the key in
internal driver hashtable to do lookups by "n" only.

Fixes: f986158bc93b ("mlxsw: spectrum_router: Add private neigh table")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Acked-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c