OSDN Git Service

can: can327: can327_feed_frame_to_netdev(): fix potential skb leak when netdev is...
authorZiyang Xuan <william.xuanziyang@huawei.com>
Thu, 10 Nov 2022 06:14:37 +0000 (14:14 +0800)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Thu, 24 Nov 2022 14:43:37 +0000 (15:43 +0100)
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>
drivers/net/can/can327.c

index 0941977..ed3d0b8 100644 (file)
@@ -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.