Skip to contentSkip to conversation

mlxsw: spectrum_mr: Fix list iteration in error path

PATCH In review Ido Schimmel 2 participants 2 messages Mar 26, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mlxsw: spectrum_mr: Fix list iteration in error path

From: Ido Schimmel <[email protected]>

list_for_each_entry_from_reverse() iterates backwards over the list from the current position, but in the error path we should start from the previous position.

Fix this by using list_for_each_entry_continue_reverse() instead.

This suppresses the following error from coccinelle:

drivers/net/ethernet/mellanox/mlxsw//spectrum_mr.c:655:34-38: ERROR:
invalid reference to the index variable of the iterator on line 636

Fixes c011ec1bbfd6 ("mlxsw: spectrum: Add the multicast routing offloading logic")
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/mellanox/mlxsw/spectrum_mr.c +4 -4
index 54275624718b..336e5ecc68f8 100644
@@ -637,12 +637,12 @@ static int mlxsw_sp_mr_vif_resolve(struct mlxsw_sp_mr_table *mr_table,
 	return 0;
 
 err_erif_unresolve:
-	list_for_each_entry_from_reverse(erve, &mr_vif->route_evif_list,
-					 vif_node)
+	list_for_each_entry_continue_reverse(erve, &mr_vif->route_evif_list,
+					     vif_node)
 		mlxsw_sp_mr_route_evif_unresolve(mr_table, erve);
 err_irif_unresolve:
-	list_for_each_entry_from_reverse(irve, &mr_vif->route_ivif_list,
-					 vif_node)
+	list_for_each_entry_continue_reverse(irve, &mr_vif->route_ivif_list,
+					     vif_node)
 		mlxsw_sp_mr_route_ivif_unresolve(mr_table, irve);
 	mr_vif->rif = NULL;
 	return err;
Signature · 1 line
2.24.1
maintainer
#1 lore raw

From: Ido Schimmel <[email protected]>
Date: Thu, 26 Mar 2020 16:17:33 +0200

Quoted 8 lines

From: Ido Schimmel <[email protected]>

list_for_each_entry_from_reverse() iterates backwards over the list from the current position, but in the error path we should start from the previous position.

Fix this by using list_for_each_entry_continue_reverse() instead.

Quoted 8 lines

This suppresses the following error from coccinelle:

drivers/net/ethernet/mellanox/mlxsw//spectrum_mr.c:655:34-38: ERROR:
invalid reference to the index variable of the iterator on line 636

Fixes c011ec1bbfd6 ("mlxsw: spectrum: Add the multicast routing offloading logic")

Applied and queued up for -stable, thanks.