I agree with you.
By the way, i find two similar questions about can_put_echo_skb. I hope
you can also check them out:
mcba_usb:
https://lore.kernel.org/all/20220311080208.45047-1-hbh25y@xxxxxxxxx/
usb_8dev:
https://lore.kernel.org/all/20220311080614.45229-1-hbh25y@xxxxxxxxx/
They are the same issue as the following patches:
https://lore.kernel.org/all/20220228083639.38183-1-hbh25y@xxxxxxxxx/
Thanks,
Hangyu Hua
On 2022/3/17 16:13, Marc Kleine-Budde wrote:
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.
Reported-by: Hangyu Hua <hbh25y@xxxxxxxxx>
Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
---
Hello,
picking up Hangyu Hua's work from:
| https://lore.kernel.org/all/20220317030143.14668-1-hbh25y@xxxxxxxxx/
Instead of using a temporary variable, move the can_put_echo_skb() instead.
regads,
Marc
drivers/net/can/m_can/m_can.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 1a4b56f6fa8c..b3b5bc1c803b 100644
--- 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 {