* [PATCH] can: m_can: fix a possible use after free in m_can_tx_handler()
@ 2022-03-17 3:01 Hangyu Hua
2022-03-17 8:11 ` Marc Kleine-Budde
0 siblings, 1 reply; 2+ messages in thread
From: Hangyu Hua @ 2022-03-17 3:01 UTC (permalink / raw)
To: rcsekar, wg, mkl, davem, kuba; +Cc: linux-can, netdev, linux-kernel, Hangyu Hua
can_put_echo_skb will clone skb then free the skb. It is better to avoid using
skb after can_put_echo_skb.
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
---
drivers/net/can/m_can/m_can.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 1a4b56f6fa8c..98be5742f4f5 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1607,6 +1607,7 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)
u32 cccr, fdflags;
int err;
int putidx;
+ unsigned int len = skb->len;
cdev->tx_skb = NULL;
@@ -1642,7 +1643,7 @@ static netdev_tx_t m_can_tx_handler(struct m_can_classdev *cdev)
if (cdev->can.ctrlmode & CAN_CTRLMODE_FD) {
cccr = m_can_read(cdev, M_CAN_CCCR);
cccr &= ~CCCR_CMR_MASK;
- if (can_is_canfd_skb(skb)) {
+ if (len == CANFD_MTU) {
if (cf->flags & CANFD_BRS)
cccr |= FIELD_PREP(CCCR_CMR_MASK,
CCCR_CMR_CANFD_BRS);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] can: m_can: fix a possible use after free in m_can_tx_handler()
2022-03-17 3:01 [PATCH] can: m_can: fix a possible use after free in m_can_tx_handler() Hangyu Hua
@ 2022-03-17 8:11 ` Marc Kleine-Budde
0 siblings, 0 replies; 2+ messages in thread
From: Marc Kleine-Budde @ 2022-03-17 8:11 UTC (permalink / raw)
To: Hangyu Hua; +Cc: rcsekar, wg, davem, kuba, linux-can, netdev, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 502 bytes --]
On 17.03.2022 11:01:43, Hangyu Hua wrote:
> can_put_echo_skb will clone skb then free the skb. It is better to avoid using
> skb after can_put_echo_skb.
Why not move the can_put_echo_skb() instead? I'll send a patch.
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-17 8:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-17 3:01 [PATCH] can: m_can: fix a possible use after free in m_can_tx_handler() Hangyu Hua
2022-03-17 8:11 ` Marc Kleine-Budde
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.