Skip to content

Commit e04b2cf

Browse files
can: m_can: m_can_tx_work_queue(): fix tx_skb race condition
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: f524f82 ("can: m_can: Create a m_can platform framework") Tested-by: Torin Cooper-Bennun <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 03c4271 commit e04b2cf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/can/m_can/m_can.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1562,6 +1562,8 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)
15621562
int i;
15631563
int putidx;
15641564

1565+
cdev->tx_skb = NULL;
1566+
15651567
/* Generate ID field for TX buffer Element */
15661568
/* Common to all supported M_CAN versions */
15671569
if (cf->can_id & CAN_EFF_FLAG) {
@@ -1678,7 +1680,6 @@ static void m_can_tx_work_queue(struct work_struct *ws)
16781680
tx_work);
16791681

16801682
m_can_tx_handler(cdev);
1681-
cdev->tx_skb = NULL;
16821683
}
16831684

16841685
static netdev_tx_t m_can_start_xmit(struct sk_buff *skb,

0 commit comments

Comments
 (0)