From patchwork Sat Sep 20 16:22:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 4175 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=178.209.62.157; helo=s3.neomailbox.net; envelope-from=antonio@meshcoding.com; receiver=b.a.t.m.a.n@lists.open-mesh.org Received: from s3.neomailbox.net (s3.neomailbox.net [178.209.62.157]) by open-mesh.org (Postfix) with ESMTPS id 7E3FA600726 for ; Sat, 20 Sep 2014 18:23:30 +0200 (CEST) From: Antonio Quartulli To: b.a.t.m.a.n@lists.open-mesh.org Date: Sat, 20 Sep 2014 18:22:05 +0200 Message-Id: <1411230125-21848-1-git-send-email-antonio@meshcoding.com> Cc: Antonio Quartulli Subject: [B.A.T.M.A.N.] [PATCH maint] batman-adv: avoid NULL dereferences and fix if check 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: Sat, 20 Sep 2014 16:23:30 -0000 Gateway having bandwidth_down equal to zero are not accepted at all and so never added to the Gateway list. For this reason checking the bandwidth_down member in batadv_gw_out_of_range() is useless. This is probably a copy/paste error and this check was supposed to be "!gw_node" only. Moreover, the way the check is written now may also lead to a NULL dereference. Fix this by rewriting the if-condition properly. Introduced by 0853ec7fafe0a195754454832993c6b35e22b842 ("batman-adv: tvlv - gateway download/upload bandwidth container") Signed-off-by: Antonio Quartulli Reported-by: David Binderman --- This patch makes "batman-adv: avoid NULL dereferences and clarify if check" obsolete. gateway_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gateway_client.c b/gateway_client.c index bcc3e0c..27649e8 100644 --- a/gateway_client.c +++ b/gateway_client.c @@ -811,7 +811,7 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, goto out; gw_node = batadv_gw_node_get(bat_priv, orig_dst_node); - if (!gw_node->bandwidth_down == 0) + if (!gw_node) goto out; switch (atomic_read(&bat_priv->gw_mode)) {