From patchwork Mon Jun 20 16:41:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 16385 Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id B1350817C0; Mon, 20 Jun 2016 18:42:34 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=unstable.cc Received-SPF: Permerror (SPF Permanent Error: Two or more type TXT spf records found.) identity=mailfrom; client-ip=5.148.176.60; helo=s2.neomailbox.net; envelope-from=a@unstable.cc; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=none header.from=unstable.cc Received: from s2.neomailbox.net (s2.neomailbox.net [5.148.176.60]) by open-mesh.org (Postfix) with ESMTPS id 11FD781788 for ; Mon, 20 Jun 2016 18:42:31 +0200 (CEST) Date: Tue, 21 Jun 2016 00:41:15 +0800 From: Antonio Quartulli To: The list for a Better Approach To Mobile Ad-hoc Networking Message-ID: <20160620164115.GD10666@prodigo> References: <1465575241-1754-1-git-send-email-sven@narfation.org> <1465575241-1754-2-git-send-email-sven@narfation.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1465575241-1754-2-git-send-email-sven@narfation.org> Subject: Re: [B.A.T.M.A.N.] [PATCH next] batman-adv: Free tp_meter ack skb when it was not consumed X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" On Fri, Jun 10, 2016 at 06:14:01PM +0200, 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 > --- > Antonio, this is not really tested. Could you please review it and tell me > if I may have missed something. > > net/batman-adv/tp_meter.c | 3 +++ > 1 file changed, 3 insertions(+) > > 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); > + Good catch, Sven ! However, how about changing the patch this way ? this is the same check we do in batadv_send_skb_unicast(). Cheers, --- a/net/batman-adv/tp_meter.c +++ b/net/batman-adv/tp_meter.c @@ -1206,7 +1206,7 @@ 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) + if ((r == -1) || !dev_xmit_complete(res)) kfree_skb(skb); if (unlikely(r < 0) || (r == NET_XMIT_DROP)) {