From: Ziyang Xuan william.xuanziyang@huawei.com
In can327_feed_frame_to_netdev(), it did not free the skb when netdev is down, and all callers of can327_feed_frame_to_netdev() did not free allocated skb too. That would trigger skb leak.
Fix it by adding kfree_skb() in can327_feed_frame_to_netdev() when netdev is down. Not tested, just compiled.
Fixes: 43da2f07622f ("can: can327: CAN/ldisc driver for ELM327 based OBD-II adapters") Signed-off-by: Ziyang Xuan william.xuanziyang@huawei.com Link: https://lore.kernel.org/all/20221110061437.411525-1-william.xuanziyang@huawe... Reviewed-by: Max Staudt max@enpas.org Cc: stable@vger.kernel.org Signed-off-by: Marc Kleine-Budde mkl@pengutronix.de --- drivers/net/can/can327.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/can327.c b/drivers/net/can/can327.c index 094197780776..ed3d0b8989a0 100644 --- a/drivers/net/can/can327.c +++ b/drivers/net/can/can327.c @@ -263,8 +263,10 @@ static void can327_feed_frame_to_netdev(struct can327 *elm, struct sk_buff *skb) { lockdep_assert_held(&elm->lock);
- if (!netif_running(elm->dev)) + if (!netif_running(elm->dev)) { + kfree_skb(skb); return; + }
/* Queue for NAPI pickup. * rx-offload will update stats and LEDs for us.
base-commit: ad17c2a3f11b0f6b122e7842d8f7d9a5fcc7ac63
Hello:
This series was applied to netdev/net.git (master) by Marc Kleine-Budde mkl@pengutronix.de:
On Thu, 24 Nov 2022 20:57:01 +0100 you wrote:
From: Ziyang Xuan william.xuanziyang@huawei.com
In can327_feed_frame_to_netdev(), it did not free the skb when netdev is down, and all callers of can327_feed_frame_to_netdev() did not free allocated skb too. That would trigger skb leak.
Fix it by adding kfree_skb() in can327_feed_frame_to_netdev() when netdev is down. Not tested, just compiled.
[...]
Here is the summary with links: - [net,1/8] can: can327: can327_feed_frame_to_netdev(): fix potential skb leak when netdev is down https://git.kernel.org/netdev/net/c/8fa452cfafed - [net,2/8] can: sja1000: fix size of OCR_MODE_MASK define https://git.kernel.org/netdev/net/c/26e8f6a75248 - [net,3/8] can: sja1000_isa: sja1000_isa_probe(): add missing free_sja1000dev() https://git.kernel.org/netdev/net/c/92dfd9310a71 - [net,4/8] can: cc770: cc770_isa_probe(): add missing free_cc770dev() https://git.kernel.org/netdev/net/c/62ec89e74099 - [net,5/8] can: etas_es58x: es58x_init_netdev(): free netdev when register_candev() https://git.kernel.org/netdev/net/c/709cb2f9ed20 - [net,6/8] can: m_can: pci: add missing m_can_class_free_dev() in probe/remove methods https://git.kernel.org/netdev/net/c/1eca1d4cc21b - [net,7/8] can: m_can: Add check for devm_clk_get https://git.kernel.org/netdev/net/c/68b4f9e0bdd0 - [net,8/8] can: mcba_usb: Fix termination command argument https://git.kernel.org/netdev/net/c/1a8e3bd25f1e
You are awesome, thank you!
linux-stable-mirror@lists.linaro.org