Skip to content

Commit 2e8e79c

Browse files
can: m_can: m_can_tx_handler(): fix use after free of skb
can_put_echo_skb() will clone skb then free the skb. Move the can_put_echo_skb() for the m_can version 3.0.x directly before the start of the xmit in hardware, similar to the 3.1.x branch. Fixes: 8064673 ("can: m_can: update to support CAN FD features") Link: https://lore.kernel.org/all/[email protected] Cc: [email protected] Reported-by: Hangyu Hua <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent fa7b514 commit 2e8e79c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/net/can/m_can/m_can.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1637,8 +1637,6 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)
16371637
if (err)
16381638
goto out_fail;
16391639

1640-
can_put_echo_skb(skb, dev, 0, 0);
1641-
16421640
if (cdev->can.ctrlmode & CAN_CTRLMODE_FD) {
16431641
cccr = m_can_read(cdev, M_CAN_CCCR);
16441642
cccr &= ~CCCR_CMR_MASK;
@@ -1655,6 +1653,9 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)
16551653
m_can_write(cdev, M_CAN_CCCR, cccr);
16561654
}
16571655
m_can_write(cdev, M_CAN_TXBTIE, 0x1);
1656+
1657+
can_put_echo_skb(skb, dev, 0, 0);
1658+
16581659
m_can_write(cdev, M_CAN_TXBAR, 0x1);
16591660
/* End of xmit function for version 3.0.x */
16601661
} else {

0 commit comments

Comments
 (0)