Skip to content

Commit 4b01bec

Browse files
vladimirolteankuba-moo
authored andcommitted
net: mscc: ocelot: fix memory leak on ocelot_port_add_txtstamp_skb()
If ocelot_port_add_txtstamp_skb() fails, for example due to a full PTP timestamp FIFO, we must undo the skb_clone_sk() call with kfree_skb(). Otherwise, the reference to the skb clone is lost. Fixes: 52849bc ("net: mscc: ocelot: avoid overflowing the PTP timestamp FIFO") Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Link: https://patch.msgid.link/20241205145519.1236778-2-vladimir.oltean@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent cdd0b91 commit 4b01bec

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/net/ethernet/mscc/ocelot_ptp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,8 +688,10 @@ int ocelot_port_txtstamp_request(struct ocelot *ocelot, int port,
688688
return -ENOMEM;
689689

690690
err = ocelot_port_add_txtstamp_skb(ocelot, port, *clone);
691-
if (err)
691+
if (err) {
692+
kfree_skb(*clone);
692693
return err;
694+
}
693695

694696
OCELOT_SKB_CB(skb)->ptp_cmd = ptp_cmd;
695697
OCELOT_SKB_CB(*clone)->ptp_class = ptp_class;

0 commit comments

Comments
 (0)