提交 f5992b72 编写于 作者: M Michael Chan 提交者: David S. Miller

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: NWang Yufen <wangyufen@huawei.com>
Signed-off-by: NMichael Chan <michael.chan@broadcom.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 6052cd1a
...@@ -8720,11 +8720,14 @@ static void tg3_free_consistent(struct tg3 *tp) ...@@ -8720,11 +8720,14 @@ static void tg3_free_consistent(struct tg3 *tp)
tg3_mem_rx_release(tp); tg3_mem_rx_release(tp);
tg3_mem_tx_release(tp); tg3_mem_tx_release(tp);
/* Protect tg3_get_stats64() from reading freed tp->hw_stats. */
tg3_full_lock(tp, 0);
if (tp->hw_stats) { if (tp->hw_stats) {
dma_free_coherent(&tp->pdev->dev, sizeof(struct tg3_hw_stats), dma_free_coherent(&tp->pdev->dev, sizeof(struct tg3_hw_stats),
tp->hw_stats, tp->stats_mapping); tp->hw_stats, tp->stats_mapping);
tp->hw_stats = NULL; tp->hw_stats = NULL;
} }
tg3_full_unlock(tp);
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册