Skip to contentSkip to conversation

sock: free skb in skb_complete_tx_timestamp on error

PATCH In review Willem de Bruijn 3 participants 3 messages Dec 13, 2017 – Dec 15, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sock: free skb in skb_complete_tx_timestamp on error

From: Willem de Bruijn <[email protected]>

skb_complete_tx_timestamp must ingest the skb it is passed. Call kfree_skb if the skb cannot be enqueued.

Fixes b245be1f4db1 ("net-timestamp: no-payload only sysctl")
Fixes 9ac25fc06375 ("net: fix socket refcounting in skb_complete_tx_timestamp()")
---
 net/core/skbuff.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/core/skbuff.c +5 -1
index 6b0ff396fa9d..a592ca025fc4 100644
@@ -4293,7 +4293,7 @@ void skb_complete_tx_timestamp(struct sk_buff *skb,
 	struct sock *sk = skb->sk;
 
 	if (!skb_may_tx_timestamp(sk, false))
-		return;
+		goto err;
 
 	/* Take a reference to prevent skb_orphan() from freeing the socket,
 	 * but only if the socket refcount is not zero.
@@ -4302,7 +4302,11 @@ void skb_complete_tx_timestamp(struct sk_buff *skb,
 		*skb_hwtstamps(skb) = *hwtstamps;
 		__skb_complete_tx_timestamp(skb, sk, SCM_TSTAMP_SND, false);
 		sock_put(sk);
+		return;
 	}
+
+err:
+	kfree_skb(skb);
 }
 EXPORT_SYMBOL_GPL(skb_complete_tx_timestamp);
 
Signature · 1 line
2.15.1.504.g5279b80103-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Willem de Bruijn

From: Willem de Bruijn <[email protected]>

skb_complete_tx_timestamp must ingest the skb it is passed. Call kfree_skb if the skb cannot be enqueued.

Fixes b245be1f4db1 ("net-timestamp: no-payload only sysctl")
Fixes 9ac25fc06375 ("net: fix socket refcounting in skb_complete_tx_timestamp()")

---

Thanks !

maintainer
#2 lore raw
In reply to Willem de Bruijn

From: Willem de Bruijn <[email protected]>
Date: Wed, 13 Dec 2017 14:41:06 -0500

Quoted 9 lines

From: Willem de Bruijn <[email protected]>

skb_complete_tx_timestamp must ingest the skb it is passed. Call kfree_skb if the skb cannot be enqueued.

Fixes b245be1f4db1 ("net-timestamp: no-payload only sysctl")
Fixes 9ac25fc06375 ("net: fix socket refcounting in skb_complete_tx_timestamp()")

Applied and queued up for -stable.