Skip to contentSkip to conversation

batman-adv: Don't dereference unchecked incoming soft_iface

PATCH Applied Sven Eckelmann 2 participants 2 messages Oct 9, 2010 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20101008093941.GH11681@bicker

#1 lore raw

PATCH 1/1 batman-adv: Don't dereference unchecked incoming soft_iface

send_packet derefenced forw_packet->if_incoming and checked if forw_packet->if_incoming is NULL.

This cannot happen, but still makes irritates when reading through the functions.

---
 batman-adv/send.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
batman-adv/send.c +5 -2
index 625a3ba..7097ff0 100644
@@ -163,8 +163,8 @@ static void send_packet_to_if(struct forw_packet *forw_packet,
 static void send_packet(struct forw_packet *forw_packet)
 {
 	struct batman_if *batman_if;
-	struct net_device *soft_iface = forw_packet->if_incoming->soft_iface;
-	struct bat_priv *bat_priv = netdev_priv(soft_iface);
+	struct net_device *soft_iface;
+	struct bat_priv *bat_priv;
 	struct batman_packet *batman_packet =
 		(struct batman_packet *)(forw_packet->skb->data);
 	unsigned char directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0);
@@ -175,6 +175,9 @@ static void send_packet(struct forw_packet *forw_packet)
 		return;
 	}
 
+	soft_iface = forw_packet->if_incoming->soft_iface;
+	bat_priv = netdev_priv(soft_iface);
+
 	if (forw_packet->if_incoming->if_status != IF_ACTIVE)
 		return;
 
Signature · 1 line
1.7.2.3
#2 lore raw
Quoted 5 lines · On Saturday 09 October 2010 02:19:42 Sven Eckelmann wrote:

send_packet derefenced forw_packet->if_incoming and checked if forw_packet->if_incoming is NULL.

This cannot happen, but still makes irritates when reading through the functions.

Applied in revision 1822.

Thanks,
Marek