Skip to content

Commit

Permalink
sock: free skb in skb_complete_tx_timestamp on error
Browse files Browse the repository at this point in the history
skb_complete_tx_timestamp must ingest the skb it is passed. Call
kfree_skb if the skb cannot be enqueued.

Fixes: b245be1 ("net-timestamp: no-payload only sysctl")
Fixes: 9ac25fc ("net: fix socket refcounting in skb_complete_tx_timestamp()")
Reported-by: Richard Cochran <richardcochran@gmail.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
wdebruij authored and davem330 committed Dec 15, 2017
1 parent d9356ed commit 35b99df
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);

Expand Down

0 comments on commit 35b99df

Please sign in to comment.