[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1304284234-27338-4-git-send-email-sven@narfation.org>
Date: Sun, 1 May 2011 23:10:33 +0200
From: Sven Eckelmann <sven@...fation.org>
To: davem@...emloft.net
Cc: netdev@...r.kernel.org, b.a.t.m.a.n@...ts.open-mesh.org,
Antonio Quartulli <ordex@...istici.org>,
Sven Eckelmann <sven@...fation.org>
Subject: [PATCH 3/4] batman-adv: fix gw_node_update() and gw_election()
From: Antonio Quartulli <ordex@...istici.org>
This is a regression from c4aac1ab9b973798163b34939b522f01e4d28ac9
- 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 <ordex@...istici.org>
Signed-off-by: Sven Eckelmann <sven@...fation.org>
---
net/batman-adv/gateway_client.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index 2acd7a6..af128ef 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -127,7 +127,7 @@ void gw_election(struct bat_priv *bat_priv)
return;
curr_gw = gw_get_selected_gw_node(bat_priv);
- if (!curr_gw)
+ if (curr_gw)
goto out;
rcu_read_lock();
@@ -310,9 +310,13 @@ void gw_node_update(struct bat_priv *bat_priv,
struct hlist_node *node;
struct gw_node *gw_node, *curr_gw;
+ /**
+ * Note: We don't need a NULL check here, since curr_gw never gets
+ * dereferenced. If curr_gw is NULL we also should not exit as we may
+ * have this gateway in our list (duplication check!) even though we
+ * have no currently selected gateway.
+ */
curr_gw = gw_get_selected_gw_node(bat_priv);
- if (!curr_gw)
- goto out;
rcu_read_lock();
hlist_for_each_entry_rcu(gw_node, node, &bat_priv->gw_list, list) {
@@ -350,7 +354,7 @@ deselect:
gw_deselect(bat_priv);
unlock:
rcu_read_unlock();
-out:
+
if (curr_gw)
gw_node_free_ref(curr_gw);
}
--
1.7.4.4
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists