mlxsw: spectrum_router: Fix rollback in tunnel next hop init
authorPetr Machata <petrm@nvidia.com>
Wed, 29 Jun 2022 07:02:05 +0000 (10:02 +0300)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 30 Jun 2022 09:35:18 +0000 (11:35 +0200)
commit665030fd0c1ed9f505932e6e73e7a2c788787a0a
treebcc947cf8f2a8e92e963d7524e097c9db3f3b18a
parent9cc02ede696272c5271a401e4f27c262359bc2f6
mlxsw: spectrum_router: Fix rollback in tunnel next hop init

In mlxsw_sp_nexthop6_init(), a next hop is always added to the router
linked list, and mlxsw_sp_nexthop_type_init() is invoked afterwards. When
that function results in an error, the next hop will not have been removed
from the linked list. As the error is propagated upwards and the caller
frees the next hop object, the linked list ends up holding an invalid
object.

A similar issue comes up with mlxsw_sp_nexthop4_init(), where rollback
block does exist, however does not include the linked list removal.

Both IPv6 and IPv4 next hops have a similar issue with next-hop counter
rollbacks. As these were introduced in the same patchset as the next hop
linked list, include the cleanup in this patch.

Fixes: dbe4598c1e92 ("mlxsw: spectrum_router: Keep nexthops in a linked list")
Fixes: a5390278a5eb ("mlxsw: spectrum: Add support for setting counters on nexthops")
Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Amit Cohen <amcohen@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Link: https://lore.kernel.org/r/20220629070205.803952-1-idosch@nvidia.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c