Skip to content

Commit

Permalink
ice: add lock around Tx timestamp tracker flush
Browse files Browse the repository at this point in the history
[ Upstream commit 4dd0d5c ]

The driver didn't take the lock while flushing the Tx tracker, which
could cause a race where one thread is trying to read timestamps out
while another thread is trying to read the tracker to check the
timestamps.

Avoid this by ensuring that flushing is locked against read accesses.

Fixes: ea9b847 ("ice: enable transmit timestamps for E810 devices")
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Gurucharan G <gurucharanx.g@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
jacob-keller authored and gregkh committed Sep 15, 2021
1 parent c0e94a8 commit 46720ac
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/net/ethernet/intel/ice/ice_ptp.c
Expand Up @@ -1278,6 +1278,8 @@ ice_ptp_flush_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx)
{
u8 idx;

spin_lock(&tx->lock);

for (idx = 0; idx < tx->len; idx++) {
u8 phy_idx = idx + tx->quad_offset;

Expand All @@ -1290,6 +1292,8 @@ ice_ptp_flush_tx_tracker(struct ice_pf *pf, struct ice_ptp_tx *tx)
tx->tstamps[idx].skb = NULL;
}
}

spin_unlock(&tx->lock);
}

/**
Expand Down

0 comments on commit 46720ac

Please sign in to comment.