[next,v2,1/4] batman-adv: Free tp_meter ack skb when it was not consumed

Message ID 1466445210-17616-1-git-send-email-sven@narfation.org (mailing list archive)
State Accepted, archived
Commit ae4987543086a574851c4f5542856ece6d2dc9a5
Delegated to: Marek Lindner
Headers

Commit Message

Sven Eckelmann June 20, 2016, 5:53 p.m. UTC
  batadv_send_skb_to_orig can return -1 to signal that the skb was not
consumed. tp_meter has then to free the skb to avoid a memory leak.

Fixes: 98d7a766b645 ("batman-adv: throughput meter implementation")
Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
v2:
 - rebased on current master
 - added patch to a common set of related patches

 net/batman-adv/tp_meter.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Marek Lindner July 5, 2016, 8:32 a.m. UTC | #1
On Monday, June 20, 2016 19:53:27 Sven Eckelmann wrote:
> batadv_send_skb_to_orig can return -1 to signal that the skb was not
> consumed. tp_meter has then to free the skb to avoid a memory leak.
> 
> Fixes: 98d7a766b645 ("batman-adv: throughput meter implementation")
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
> v2:
>  - rebased on current master
>  - added patch to a common set of related patches
> 
>  net/batman-adv/tp_meter.c | 3 +++
>  1 file changed, 3 insertions(+)

Applied in revision ae49875.

Thanks,
Marek
  

Patch

diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c
index bf6bffb..2333777 100644
--- a/net/batman-adv/tp_meter.c
+++ b/net/batman-adv/tp_meter.c
@@ -1206,6 +1206,9 @@  static int batadv_tp_send_ack(struct batadv_priv *bat_priv, const u8 *dst,
 
 	/* send the ack */
 	r = batadv_send_skb_to_orig(skb, orig_node, NULL);
+	if (r == -1)
+		kfree_skb(skb);
+
 	if (unlikely(r < 0) || (r == NET_XMIT_DROP)) {
 		ret = BATADV_TP_REASON_DST_UNREACHABLE;
 		goto out;