Commit 35b99dff authored by Willem de Bruijn's avatar Willem de Bruijn Committed by David S. Miller

sock: free skb in skb_complete_tx_timestamp on error

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

Fixes: b245be1f ("net-timestamp: no-payload only sysctl")
Fixes: 9ac25fc0 ("net: fix socket refcounting in skb_complete_tx_timestamp()")
Reported-by: default avatarRichard Cochran <richardcochran@gmail.com>
Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
Reviewed-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d9356edc
...@@ -4293,7 +4293,7 @@ void skb_complete_tx_timestamp(struct sk_buff *skb, ...@@ -4293,7 +4293,7 @@ void skb_complete_tx_timestamp(struct sk_buff *skb,
struct sock *sk = skb->sk; struct sock *sk = skb->sk;
if (!skb_may_tx_timestamp(sk, false)) if (!skb_may_tx_timestamp(sk, false))
return; goto err;
/* Take a reference to prevent skb_orphan() from freeing the socket, /* Take a reference to prevent skb_orphan() from freeing the socket,
* but only if the socket refcount is not zero. * but only if the socket refcount is not zero.
...@@ -4302,7 +4302,11 @@ void skb_complete_tx_timestamp(struct sk_buff *skb, ...@@ -4302,7 +4302,11 @@ void skb_complete_tx_timestamp(struct sk_buff *skb,
*skb_hwtstamps(skb) = *hwtstamps; *skb_hwtstamps(skb) = *hwtstamps;
__skb_complete_tx_timestamp(skb, sk, SCM_TSTAMP_SND, false); __skb_complete_tx_timestamp(skb, sk, SCM_TSTAMP_SND, false);
sock_put(sk); sock_put(sk);
return;
} }
err:
kfree_skb(skb);
} }
EXPORT_SYMBOL_GPL(skb_complete_tx_timestamp); EXPORT_SYMBOL_GPL(skb_complete_tx_timestamp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment