Skip to content

Commit f5992b7

Browse files
Michael Chandavem330
authored andcommitted
tg3: Fix race condition in tg3_get_stats64().
The driver's ndo_get_stats64() method is not always called under RTNL. So it can race with driver close or ethtool reconfigurations. Fix the race condition by taking tp->lock spinlock in tg3_free_consistent() when freeing the tp->hw_stats memory block. tg3_get_stats64() is already taking tp->lock. Reported-by: Wang Yufen <[email protected]> Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6052cd1 commit f5992b7

File tree

1 file changed

+3
-0
lines changed
  • drivers/net/ethernet/broadcom

1 file changed

+3
-0
lines changed

drivers/net/ethernet/broadcom/tg3.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8720,11 +8720,14 @@ static void tg3_free_consistent(struct tg3 *tp)
87208720
tg3_mem_rx_release(tp);
87218721
tg3_mem_tx_release(tp);
87228722

8723+
/* Protect tg3_get_stats64() from reading freed tp->hw_stats. */
8724+
tg3_full_lock(tp, 0);
87238725
if (tp->hw_stats) {
87248726
dma_free_coherent(&tp->pdev->dev, sizeof(struct tg3_hw_stats),
87258727
tp->hw_stats, tp->stats_mapping);
87268728
tp->hw_stats = NULL;
87278729
}
8730+
tg3_full_unlock(tp);
87288731
}
87298732

87308733
/*

0 commit comments

Comments
 (0)