summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Oltean <vladimir.oltean@nxp.com>2024-12-05 16:55:15 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-12-19 18:13:13 +0100
commitb12cdb8f2e9c72f5f6d07d00ff44f5564c22856e (patch)
tree60300338d611d2e9640597c0798b73b97f76ed77
parent6610c7f8a8d47fd1123eed55ba8c11c2444d8842 (diff)
net: mscc: ocelot: fix memory leak on ocelot_port_add_txtstamp_skb()
[ Upstream commit 4b01bec25bef62544228bce06db6a3afa5d3d6bb ] 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: 52849bcf0029 ("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> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/net/ethernet/mscc/ocelot_ptp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/net/ethernet/mscc/ocelot_ptp.c b/drivers/net/ethernet/mscc/ocelot_ptp.c
index e172638b0601..db00a51a7430 100644
--- a/drivers/net/ethernet/mscc/ocelot_ptp.c
+++ b/drivers/net/ethernet/mscc/ocelot_ptp.c
@@ -688,8 +688,10 @@ int ocelot_port_txtstamp_request(struct ocelot *ocelot, int port,
return -ENOMEM;
err = ocelot_port_add_txtstamp_skb(ocelot, port, *clone);
- if (err)
+ if (err) {
+ kfree_skb(*clone);
return err;
+ }
OCELOT_SKB_CB(skb)->ptp_cmd = ptp_cmd;
OCELOT_SKB_CB(*clone)->ptp_class = ptp_class;