Commit 94b05072 authored by Anssi Hannula's avatar Anssi Hannula Committed by Greg Kroah-Hartman
Browse files

can: xilinx_can: xcan_write_frame(): fix use-after-free of transmitted SKB



[ Upstream commit ef79f00b ]

can_put_echo_skb() takes ownership of the SKB and it may be freed
during or after the call.

However, xilinx_can xcan_write_frame() keeps using SKB after the call.

Fix that by only calling can_put_echo_skb() after the code is done
touching the SKB.

The tx_lock is held for the entire xcan_write_frame() execution and
also on the can_get_echo_skb() side so the order of operations does not
matter.

An earlier fix commit 3d3c817c ("can: xilinx_can: Fix usage of skb
memory") did not move the can_put_echo_skb() call far enough.

Signed-off-by: default avatarAnssi Hannula <anssi.hannula@bitwise.fi>
Fixes: 1598efe5 ("can: xilinx_can: refactor code in preparation for CAN FD support")
Link: https://patch.msgid.link/20250822095002.168389-1-anssi.hannula@bitwise.fi


[mkl: add "commit" in front of sha1 in patch description]
[mkl: fix indention]
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent deedea59
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment