From patchwork Sun Nov 24 13:05:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 3684 Return-Path: Received: from mail.mail.packetmixer.de (packetmixer.de [79.140.42.25]) by open-mesh.org (Postfix) with ESMTPS id 336B3602260 for ; Sun, 24 Nov 2013 14:05:50 +0100 (CET) Received: from kero.packetmixer.de (p4FFE57BD.dip0.t-ipconnect.de [79.254.87.189]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.mail.packetmixer.de (Postfix) with ESMTPSA id B304A62407; Sun, 24 Nov 2013 13:17:57 +0000 (UTC) From: Simon Wunderlich To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 24 Nov 2013 14:05:45 +0100 Message-Id: <1385298345-13746-3-git-send-email-sw@simonwunderlich.de> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1385298345-13746-1-git-send-email-sw@simonwunderlich.de> References: <1385298345-13746-1-git-send-email-sw@simonwunderlich.de> Cc: Simon Wunderlich Subject: [B.A.T.M.A.N.] [PATCH 3/3] batman-adv: fix rcu pointer comparison problem X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Nov 2013 13:05:50 -0000 From: Simon Wunderlich sparse complained about: routing.c:482:64: error: incompatible types in comparison expression (different address spaces) This was due to comparing a __rcu pointer with a regular one. Fix that by adding the missing rcu_dereference call. A temporary variable is used to comply with the line length limit, use the opportunity to beautify a few other places. This problem was introduced in commit 797edd9e87ac838711e03498a4ae795b600191af ("batman-adv: add bonding again") Signed-off-by: Simon Wunderlich --- routing.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/routing.c b/routing.c index 23311f5..7aac5b3 100644 --- a/routing.c +++ b/routing.c @@ -430,8 +430,10 @@ batadv_find_router(struct batadv_priv *bat_priv, struct batadv_neigh_node *first_candidate_router = NULL; struct batadv_neigh_node *next_candidate_router = NULL; struct batadv_neigh_node *router, *cand_router = NULL; + struct batadv_neigh_node *last_cand_router = NULL; struct batadv_orig_ifinfo *cand, *first_candidate = NULL; struct batadv_orig_ifinfo *next_candidate = NULL; + struct batadv_orig_ifinfo *last_candidate; bool last_candidate_found = false; if (!orig_node) @@ -455,6 +457,10 @@ batadv_find_router(struct batadv_priv *bat_priv, * router - obviously there are no other candidates. */ rcu_read_lock(); + last_candidate = orig_node->last_bonding_candidate; + if (last_candidate) + last_cand_router = rcu_dereference(last_candidate->router); + hlist_for_each_entry_rcu(cand, &orig_node->ifinfo_list, list) { /* acquire some structures and references ... */ if (!atomic_inc_not_zero(&cand->refcount)) @@ -478,9 +484,8 @@ batadv_find_router(struct batadv_priv *bat_priv, goto next; /* don't use the same router twice */ - if (orig_node->last_bonding_candidate && - (orig_node->last_bonding_candidate->router == cand_router)) - goto next; + if (last_cand_router == cand_router) + goto next; /* mark the first possible candidate */ if (!first_candidate) { @@ -494,14 +499,13 @@ batadv_find_router(struct batadv_priv *bat_priv, * candidate ... this function should select the next candidate * AFTER the previously used bonding candidate. */ - if (!orig_node->last_bonding_candidate || - last_candidate_found) { + if (!last_candidate || last_candidate_found) { next_candidate = cand; next_candidate_router = cand_router; break; } - if (orig_node->last_bonding_candidate == cand) + if (last_candidate == cand) last_candidate_found = true; next: /* free references */