net: phy: mscc: Fix memory leak when using one step timestamping

[ Upstream commit 846992645b25ec4253167e3f931e4597eb84af56 ]

Fix memory leak when running one-step timestamping. When running
one-step sync timestamping, the HW is configured to insert the TX time
into the frame, so there is no reason to keep the skb anymore. As in
this case the HW will never generate an interrupt to say that the frame
was timestamped, then the frame will never released.
Fix this by freeing the frame in case of one-step timestamping.

Fixes: 7d272e63e0 ("net: phy: mscc: timestamping and PHC support")
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Link: https://patch.msgid.link/20250522115722.2827199-1-horatiu.vultur@microchip.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Horatiu Vultur
2025-05-22 13:57:22 +02:00
committed by Greg Kroah-Hartman
parent 6486f11cce
commit 0b40aeaf83

View File

@@ -1165,18 +1165,24 @@ static void vsc85xx_txtstamp(struct mii_timestamper *mii_ts,
container_of(mii_ts, struct vsc8531_private, mii_ts); container_of(mii_ts, struct vsc8531_private, mii_ts);
if (!vsc8531->ptp->configured) if (!vsc8531->ptp->configured)
return; goto out;
if (vsc8531->ptp->tx_type == HWTSTAMP_TX_OFF) { if (vsc8531->ptp->tx_type == HWTSTAMP_TX_OFF)
kfree_skb(skb); goto out;
return;
} if (vsc8531->ptp->tx_type == HWTSTAMP_TX_ONESTEP_SYNC)
if (ptp_msg_is_sync(skb, type))
goto out;
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
mutex_lock(&vsc8531->ts_lock); mutex_lock(&vsc8531->ts_lock);
__skb_queue_tail(&vsc8531->ptp->tx_queue, skb); __skb_queue_tail(&vsc8531->ptp->tx_queue, skb);
mutex_unlock(&vsc8531->ts_lock); mutex_unlock(&vsc8531->ts_lock);
return;
out:
kfree_skb(skb);
} }
static bool vsc85xx_rxtstamp(struct mii_timestamper *mii_ts, static bool vsc85xx_rxtstamp(struct mii_timestamper *mii_ts,