Skip to content

Commit 35b99df

Browse files
wdebruijdavem330
authored andcommitted
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: b245be1 ("net-timestamp: no-payload only sysctl") Fixes: 9ac25fc ("net: fix socket refcounting in skb_complete_tx_timestamp()") Reported-by: Richard Cochran <[email protected]> Signed-off-by: Willem de Bruijn <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d9356ed commit 35b99df

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

net/core/skbuff.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4293,7 +4293,7 @@ void skb_complete_tx_timestamp(struct sk_buff *skb,
42934293
struct sock *sk = skb->sk;
42944294

42954295
if (!skb_may_tx_timestamp(sk, false))
4296-
return;
4296+
goto err;
42974297

42984298
/* Take a reference to prevent skb_orphan() from freeing the socket,
42994299
* but only if the socket refcount is not zero.
@@ -4302,7 +4302,11 @@ void skb_complete_tx_timestamp(struct sk_buff *skb,
43024302
*skb_hwtstamps(skb) = *hwtstamps;
43034303
__skb_complete_tx_timestamp(skb, sk, SCM_TSTAMP_SND, false);
43044304
sock_put(sk);
4305+
return;
43054306
}
4307+
4308+
err:
4309+
kfree_skb(skb);
43064310
}
43074311
EXPORT_SYMBOL_GPL(skb_complete_tx_timestamp);
43084312

0 commit comments

Comments
 (0)