Skip to content

Commit 8469926

Browse files
HoratiuVulturkuba-moo
authored andcommitted
net: phy: mscc: Fix memory leak when using one step timestamping
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: 7d272e6 ("net: phy: mscc: timestamping and PHC support") Signed-off-by: Horatiu Vultur <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 65484f9 commit 8469926

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

drivers/net/phy/mscc/mscc_ptp.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1166,18 +1166,24 @@ static void vsc85xx_txtstamp(struct mii_timestamper *mii_ts,
11661166
container_of(mii_ts, struct vsc8531_private, mii_ts);
11671167

11681168
if (!vsc8531->ptp->configured)
1169-
return;
1169+
goto out;
11701170

1171-
if (vsc8531->ptp->tx_type == HWTSTAMP_TX_OFF) {
1172-
kfree_skb(skb);
1173-
return;
1174-
}
1171+
if (vsc8531->ptp->tx_type == HWTSTAMP_TX_OFF)
1172+
goto out;
1173+
1174+
if (vsc8531->ptp->tx_type == HWTSTAMP_TX_ONESTEP_SYNC)
1175+
if (ptp_msg_is_sync(skb, type))
1176+
goto out;
11751177

11761178
skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
11771179

11781180
mutex_lock(&vsc8531->ts_lock);
11791181
__skb_queue_tail(&vsc8531->ptp->tx_queue, skb);
11801182
mutex_unlock(&vsc8531->ts_lock);
1183+
return;
1184+
1185+
out:
1186+
kfree_skb(skb);
11811187
}
11821188

11831189
static bool vsc85xx_rxtstamp(struct mii_timestamper *mii_ts,

0 commit comments

Comments
 (0)