Skip to content

Commit 8ade3ef

Browse files
author
Al Stone
committed
can: can327: can327_feed_frame_to_netdev(): fix potential skb leak when netdev is down
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2071839 Tested: This is one of a series of patch sets to enable Arm SystemReady IR support. This set updates the CAN driver subsystem. This set has been tested on NXP imx8mm and NV Jetson Xavier NX via simple boot tests, using cansend/candump from can-utils to pass messages through a virtual CAN interface, and of course the CI loop. commit 8fa452c Author: Ziyang Xuan <william.xuanziyang@huawei.com> Date: Thu Nov 10 14:14:37 2022 +0800 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: 43da2f0 ("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> (cherry picked from commit 8fa452c) Signed-off-by: Al Stone <ahs3@redhat.com>
1 parent daf9f48 commit 8ade3ef

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/net/can/can327.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,10 @@ static void can327_feed_frame_to_netdev(struct can327 *elm, struct sk_buff *skb)
263263
{
264264
lockdep_assert_held(&elm->lock);
265265

266-
if (!netif_running(elm->dev))
266+
if (!netif_running(elm->dev)) {
267+
kfree_skb(skb);
267268
return;
269+
}
268270

269271
/* Queue for NAPI pickup.
270272
* rx-offload will update stats and LEDs for us.

0 commit comments

Comments
 (0)