summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>2021-09-07 20:29:40 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-09-22 12:28:06 +0200
commit47bc9c3929eb0bafe805bf87474615c8596d16bc (patch)
tree143db66c597c88f43c38745f1f48b47eb2325a7a
parentb2f9b7455baf8ba12113520cdf0398b6141ae42f (diff)
downloadlinux-stable-47bc9c3929eb0bafe805bf87474615c8596d16bc.tar.gz
linux-stable-47bc9c3929eb0bafe805bf87474615c8596d16bc.tar.bz2
linux-stable-47bc9c3929eb0bafe805bf87474615c8596d16bc.zip
net: renesas: sh_eth: Fix freeing wrong tx descriptor
[ Upstream commit 0341d5e3d1ee2a36dd5a49b5bef2ce4ad1cfa6b4 ] The cur_tx counter must be incremented after TACT bit of txdesc->status was set. However, a CPU is possible to reorder instructions and/or memory accesses between cur_tx and txdesc->status. And then, if TX interrupt happened at such a timing, the sh_eth_tx_free() may free the descriptor wrongly. So, add wmb() before cur_tx++. Otherwise NETDEV WATCHDOG timeout is possible to happen. Fixes: 86a74ff21a7a ("net: sh_eth: add support for Renesas SuperH Ethernet") Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/net/ethernet/renesas/sh_eth.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 5cab2d3c0023..8927d5997745 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -2533,6 +2533,7 @@ static netdev_tx_t sh_eth_start_xmit(struct sk_buff *skb,
else
txdesc->status |= cpu_to_le32(TD_TACT);
+ wmb(); /* cur_tx must be incremented after TACT bit was set */
mdp->cur_tx++;
if (!(sh_eth_read(ndev, EDTRR) & mdp->cd->edtrr_trns))