projects
/
platform
/
kernel
/
linux-starfive.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
fa7b514
)
can: m_can: m_can_tx_handler(): fix use after free of skb
author
Marc Kleine-Budde
<mkl@pengutronix.de>
Thu, 17 Mar 2022 07:57:35 +0000
(08:57 +0100)
committer
Marc Kleine-Budde
<mkl@pengutronix.de>
Thu, 31 Mar 2022 07:55:27 +0000
(09:55 +0200)
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: 80646733f11c ("can: m_can: update to support CAN FD features")
Link:
https://lore.kernel.org/all/20220317081305.739554-1-mkl@pengutronix.de
Cc: stable@vger.kernel.org
Reported-by: Hangyu Hua <hbh25y@gmail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/m_can/m_can.c
patch
|
blob
|
history
diff --git
a/drivers/net/can/m_can/m_can.c
b/drivers/net/can/m_can/m_can.c
index 1a4b56f6fa8c6a0383f463091097579f881c902d..b3b5bc1c803b3c4fd6d0428b2372a64b82de85f0 100644
(file)
--- a/
drivers/net/can/m_can/m_can.c
+++ b/
drivers/net/can/m_can/m_can.c
@@
-1637,8
+1637,6
@@
static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)
if (err)
goto out_fail;
- can_put_echo_skb(skb, dev, 0, 0);
-
if (cdev->can.ctrlmode & CAN_CTRLMODE_FD) {
cccr = m_can_read(cdev, M_CAN_CCCR);
cccr &= ~CCCR_CMR_MASK;
@@
-1655,6
+1653,9
@@
static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)
m_can_write(cdev, M_CAN_CCCR, cccr);
}
m_can_write(cdev, M_CAN_TXBTIE, 0x1);
+
+ can_put_echo_skb(skb, dev, 0, 0);
+
m_can_write(cdev, M_CAN_TXBAR, 0x1);
/* End of xmit function for version 3.0.x */
} else {