[2/2] batman-adv: Ensure that we really have route changes in update_route

Message ID 1305019357-27050-3-git-send-email-sven@narfation.org (mailing list archive)
State Accepted, archived
Commit 3e7fe2ecb85e6f1f94b6fdf9d344931c267898f1
Headers

Commit Message

Sven Eckelmann May 10, 2011, 9:22 a.m. UTC
  The debug output of update_route has tests for "route deleted" and "route
added". All other situations are handled as "route changed". This is not
true because neigh_node and curr_router could be both NULL.

The function is not called in this situation, but the code might be
interpreted wrong when reading it without this test.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 routing.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
  

Comments

Marek Lindner May 22, 2011, 10:29 a.m. UTC | #1
On Tuesday 10 May 2011 11:22:37 Sven Eckelmann wrote:
> The debug output of update_route has tests for "route deleted" and "route
> added". All other situations are handled as "route changed". This is not
> true because neigh_node and curr_router could be both NULL.
> 
> The function is not called in this situation, but the code might be
> interpreted wrong when reading it without this test.

Applied in revision 3e7fe2e.

Thanks,
Marek
  

Patch

diff --git a/routing.c b/routing.c
index 8c403ce..3f8355c 100644
--- a/routing.c
+++ b/routing.c
@@ -109,7 +109,7 @@  static void update_route(struct bat_priv *bat_priv,
 				    tt_buff, tt_buff_len);
 
 	/* route changed */
-	} else {
+	} else if (neigh_node && curr_router) {
 		bat_dbg(DBG_ROUTES, bat_priv,
 			"Changing route towards: %pM "
 			"(now via %pM - was via %pM)\n",