Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 71e4aa9

Browse files
Antonio Quartulliecsv
authored andcommitted
batman-adv: fix gw_node_update() and gw_election()
This is a regression from c4aac1a - gw_node_update() doesn't add a new gw_node in case of empty curr_gw. This means that at the beginning no gw_node is added, leading to an empty gateway list. - gw_election() is terminating in case of curr_gw == NULL. It has to terminate in case of curr_gw != NULL Signed-off-by: Antonio Quartulli <[email protected]> Signed-off-by: Sven Eckelmann <[email protected]>
1 parent 5f657ec commit 71e4aa9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

net/batman-adv/gateway_client.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ void gw_election(struct bat_priv *bat_priv)
127127
return;
128128

129129
curr_gw = gw_get_selected_gw_node(bat_priv);
130-
if (!curr_gw)
130+
if (curr_gw)
131131
goto out;
132132

133133
rcu_read_lock();
@@ -310,9 +310,13 @@ void gw_node_update(struct bat_priv *bat_priv,
310310
struct hlist_node *node;
311311
struct gw_node *gw_node, *curr_gw;
312312

313+
/**
314+
* Note: We don't need a NULL check here, since curr_gw never gets
315+
* dereferenced. If curr_gw is NULL we also should not exit as we may
316+
* have this gateway in our list (duplication check!) even though we
317+
* have no currently selected gateway.
318+
*/
313319
curr_gw = gw_get_selected_gw_node(bat_priv);
314-
if (!curr_gw)
315-
goto out;
316320

317321
rcu_read_lock();
318322
hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) {
@@ -350,7 +354,7 @@ void gw_node_update(struct bat_priv *bat_priv,
350354
gw_deselect(bat_priv);
351355
unlock:
352356
rcu_read_unlock();
353-
out:
357+
354358
if (curr_gw)
355359
gw_node_free_ref(curr_gw);
356360
}

0 commit comments

Comments
 (0)