lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1543561202-614-1-git-send-email-wen.yang99@zte.com.cn>
Date:   Fri, 30 Nov 2018 15:00:02 +0800
From:   Wen Yang <wen.yang99@....com.cn>
To:     mareklindner@...mailbox.ch, sw@...onwunderlich.de, a@...table.cc,
        davem@...emloft.net
Cc:     netdev@...r.kernel.org, b.a.t.m.a.n@...ts.open-mesh.org,
        linux-kernel@...r.kernel.org, zhong.weidong@....com.cn,
        wen.yang99@....com.cn
Subject: [PATCH] batman-adv: fix null pointer dereference in batadv_gw_election

This patch fixes a possible null pointer dereference in
batadv_gw_election, detected by the semantic patch
deref_null.cocci, with the following warning:

./net/batman-adv/gateway_client.c:289:15-24: ERROR: next_gw is NULL but dereferenced.
./net/batman-adv/gateway_client.c:290:15-29: ERROR: next_gw is NULL but dereferenced.
./net/batman-adv/gateway_client.c:291:15-29: ERROR: next_gw is NULL but dereferenced.
./net/batman-adv/gateway_client.c:292:15-27: ERROR: next_gw is NULL but dereferenced.
./net/batman-adv/gateway_client.c:293:15-27: ERROR: next_gw is NULL but dereferenced.

Signed-off-by: Wen Yang <wen.yang99@....com.cn>
Reviewed-by: Tan Hu <tan.hu@....com.cn>
---
 net/batman-adv/gateway_client.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
index 140c61a..d80ef1c 100644
--- a/net/batman-adv/gateway_client.c
+++ b/net/batman-adv/gateway_client.c
@@ -284,14 +284,16 @@ void batadv_gw_election(struct batadv_priv *bat_priv)
 		batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_ADD,
 				    gw_addr);
 	} else {
-		batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
-			   "Changing route to gateway %pM (bandwidth: %u.%u/%u.%u MBit, tq: %i)\n",
-			   next_gw->orig_node->orig,
-			   next_gw->bandwidth_down / 10,
-			   next_gw->bandwidth_down % 10,
-			   next_gw->bandwidth_up / 10,
-			   next_gw->bandwidth_up % 10,
-			   router_ifinfo->bat_iv.tq_avg);
+		if (next_gw) {
+			batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
+				   "Changing route to gateway %pM (bandwidth: %u.%u/%u.%u MBit, tq: %i)\n",
+				    next_gw->orig_node->orig,
+				    next_gw->bandwidth_down / 10,
+				    next_gw->bandwidth_down % 10,
+				    next_gw->bandwidth_up / 10,
+				    next_gw->bandwidth_up % 10,
+				    router_ifinfo->bat_iv.tq_avg);
+		}
 		batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_CHANGE,
 				    gw_addr);
 	}
-- 
2.9.5

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ