Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

can: can327: can327_feed_frame_to_netdev(): fix potential skb leak when netdev is down

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@huawei.com
Reviewed-by: Max Staudt <max@enpas.org>
Cc: stable@vger.kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

authored by

Ziyang Xuan and committed by
Marc Kleine-Budde
8fa452cf ad17c2a3

+3 -1
+3 -1
drivers/net/can/can327.c
··· 263 263 { 264 264 lockdep_assert_held(&elm->lock); 265 265 266 - if (!netif_running(elm->dev)) 266 + if (!netif_running(elm->dev)) { 267 + kfree_skb(skb); 267 268 return; 269 + } 268 270 269 271 /* Queue for NAPI pickup. 270 272 * rx-offload will update stats and LEDs for us.