can: m_can: m_can_tx_work_queue(): fix tx_skb race condition
authorMarc Kleine-Budde <mkl@pengutronix.de>
Wed, 5 May 2021 11:32:27 +0000 (13:32 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 May 2021 08:13:08 +0000 (10:13 +0200)
commit26359d362c93bdca3038f7f70d28d5ed46222a03
treea1d50f61d9e383002d4ba39b6864a9942be8f159
parenteecb4df8ec9f896b19ee05bfa632ac6c1dcd8f21
can: m_can: m_can_tx_work_queue(): fix tx_skb race condition

[ Upstream commit e04b2cfe61072c7966e1a5fb73dd1feb30c206ed ]

The m_can_start_xmit() function checks if the cdev->tx_skb is NULL and
returns with NETDEV_TX_BUSY in case tx_sbk is not NULL.

There is a race condition in the m_can_tx_work_queue(), where first
the skb is send to the driver and then the case tx_sbk is set to NULL.
A TX complete IRQ might come in between and wake the queue, which
results in tx_skb not being cleared yet.

Fixes: f524f829b75a ("can: m_can: Create a m_can platform framework")
Tested-by: Torin Cooper-Bennun <torin@maxiluxsystems.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/can/m_can/m_can.c