can: m_can: m_can_tx_handler(): fix use after free of skb
authorMarc Kleine-Budde <mkl@pengutronix.de>
Thu, 17 Mar 2022 07:57:35 +0000 (08:57 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:22:53 +0000 (14:22 +0200)
commitf43e64076ff1b1dcb893fb77ad1204105f710a29
tree9ac499f21c401e5402ae3c0177f7f859b4ac41f9
parent459b19f42fd5e031e743dfa119f44aba0b62ff97
can: m_can: m_can_tx_handler(): fix use after free of skb

commit 2e8e79c416aae1de224c0f1860f2e3350fa171f8 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/can/m_can/m_can.c