batman-adv: Remove orig_node reference handling from send_skb_unicast

The function batadv_send_skb_unicast is not acquiring a reference for an
orig_node nor removing it from any datastructure. It still reduces the
reference counter for an object which is still in the hands of the caller.

This is confusing and can lead in the future to problems in the reference
handling of the caller function.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Acked-by: Linus Lüssing <linus.luessing@c0d3.blue>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
This commit is contained in:
Sven Eckelmann 2016-06-27 08:15:42 +02:00 committed by Simon Wunderlich
parent 86452f81d2
commit f19dc7770f
2 changed files with 20 additions and 8 deletions

View File

@ -315,8 +315,7 @@ out:
* *
* Wrap the given skb into a batman-adv unicast or unicast-4addr header * Wrap the given skb into a batman-adv unicast or unicast-4addr header
* depending on whether BATADV_UNICAST or BATADV_UNICAST_4ADDR was supplied * depending on whether BATADV_UNICAST or BATADV_UNICAST_4ADDR was supplied
* as packet_type. Then send this frame to the given orig_node and release a * as packet_type. Then send this frame to the given orig_node.
* reference to this orig_node.
* *
* Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise. * Return: NET_XMIT_DROP in case of error or NET_XMIT_SUCCESS otherwise.
*/ */
@ -370,8 +369,6 @@ int batadv_send_skb_unicast(struct batadv_priv *bat_priv,
ret = NET_XMIT_SUCCESS; ret = NET_XMIT_SUCCESS;
out: out:
if (orig_node)
batadv_orig_node_put(orig_node);
if (ret == NET_XMIT_DROP) if (ret == NET_XMIT_DROP)
kfree_skb(skb); kfree_skb(skb);
return ret; return ret;
@ -403,6 +400,7 @@ int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
struct ethhdr *ethhdr = (struct ethhdr *)skb->data; struct ethhdr *ethhdr = (struct ethhdr *)skb->data;
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
u8 *src, *dst; u8 *src, *dst;
int ret;
src = ethhdr->h_source; src = ethhdr->h_source;
dst = ethhdr->h_dest; dst = ethhdr->h_dest;
@ -414,8 +412,13 @@ int batadv_send_skb_via_tt_generic(struct batadv_priv *bat_priv,
} }
orig_node = batadv_transtable_search(bat_priv, src, dst, vid); orig_node = batadv_transtable_search(bat_priv, src, dst, vid);
return batadv_send_skb_unicast(bat_priv, skb, packet_type, ret = batadv_send_skb_unicast(bat_priv, skb, packet_type,
packet_subtype, orig_node, vid); packet_subtype, orig_node, vid);
if (orig_node)
batadv_orig_node_put(orig_node);
return ret;
} }
/** /**
@ -433,10 +436,16 @@ int batadv_send_skb_via_gw(struct batadv_priv *bat_priv, struct sk_buff *skb,
unsigned short vid) unsigned short vid)
{ {
struct batadv_orig_node *orig_node; struct batadv_orig_node *orig_node;
int ret;
orig_node = batadv_gw_get_selected_orig(bat_priv); orig_node = batadv_gw_get_selected_orig(bat_priv);
return batadv_send_skb_unicast(bat_priv, skb, BATADV_UNICAST_4ADDR, ret = batadv_send_skb_unicast(bat_priv, skb, BATADV_UNICAST_4ADDR,
BATADV_P_DATA, orig_node, vid); BATADV_P_DATA, orig_node, vid);
if (orig_node)
batadv_orig_node_put(orig_node);
return ret;
} }
/** /**

View File

@ -57,6 +57,7 @@
#include "hard-interface.h" #include "hard-interface.h"
#include "multicast.h" #include "multicast.h"
#include "network-coding.h" #include "network-coding.h"
#include "originator.h"
#include "packet.h" #include "packet.h"
#include "send.h" #include "send.h"
#include "sysfs.h" #include "sysfs.h"
@ -377,6 +378,8 @@ dropped:
dropped_freed: dropped_freed:
batadv_inc_counter(bat_priv, BATADV_CNT_TX_DROPPED); batadv_inc_counter(bat_priv, BATADV_CNT_TX_DROPPED);
end: end:
if (mcast_single_orig)
batadv_orig_node_put(mcast_single_orig);
if (primary_if) if (primary_if)
batadv_hardif_put(primary_if); batadv_hardif_put(primary_if);
return NETDEV_TX_OK; return NETDEV_TX_OK;