Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp589621pxb; Tue, 5 Apr 2022 15:07:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyp1sntlwajCjm1YM7+2+esAaZiKW5ioN0UJPz5S8zbUEOahJFFKt8BY6jGw5yZNtTvUME8 X-Received: by 2002:a17:903:40cd:b0:154:abdd:929d with SMTP id t13-20020a17090340cd00b00154abdd929dmr5647439pld.96.1649196470771; Tue, 05 Apr 2022 15:07:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649196470; cv=none; d=google.com; s=arc-20160816; b=a4s+TG13IpxDJrFRsDD54c1GOhn/choQAduyKV/kQcGYFN8SEPBKRdbBMkmSAJ5v5/ yq6LHXjocHlPQlrmopTQ/Kkd5WrtKwZdMYBYwJzr+60+poOHBfIa9c0hVzn88t0S94BS BjXc0kOv9OypnLTWUREs8y0a8xf/OeepCaXdYyOZKr7kW1Qtu+QfyNtclUmMpXCUc9+p N++Cn26Kpqs5rkfflwCFp2DF4O6idBUjIfyYPo9MLbx4LZgfwie2306jo/lyZNDgDmkX XE8oiUcIg9LOWKg11xM7Eny7durLIPztMQV/2RuY07PgcoQpieK8BG8kUOltVF4kpUt+ kkaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pnFJXMxh51JhihMLdpefVwzeHFFeghCfUVgBijE8kxo=; b=ZzHJum3oAEdMF8iC31WIlwaf0Lmhi4m6/nreg+iMXyla1ir3f5f90ygH3MZs80ftvY clpf/pwdJnppuIU8nj3EvvO6WIKQF+p3SiY2cnIpUeMnYNzP+STSP/OrQD/jPEpaxj3/ cCpzAh05uaeJOGi36GWplaNoIfWNg/igUokHBXjEJyavO3Imvg1q8fTAMXup6iTlPJNy OQiLREQ/sAd2TZ8zKlvZe+nmUvPdljLzHt6OLGeTUEeQ5cmWdC3Xq5sNaFENYooTasJk HcJFV4rFv427RApAHWyXW0eeItBuX8ddwU4n0bMCTv0Jfg3oBiGB/fbGIBy5/5W1wOMX qTKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Xo6Xyd9Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id mn7-20020a17090b188700b001c7e26d8fbesi2884875pjb.107.2022.04.05.15.07.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 15:07:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Xo6Xyd9Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 36995A0BF1; Tue, 5 Apr 2022 14:50:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384393AbiDEOSC (ORCPT + 99 others); Tue, 5 Apr 2022 10:18:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239053AbiDEJdU (ORCPT ); Tue, 5 Apr 2022 05:33:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70092255AF; Tue, 5 Apr 2022 02:21:49 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 33C5FB81B14; Tue, 5 Apr 2022 09:21:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E352C385A2; Tue, 5 Apr 2022 09:21:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150507; bh=At1UesPDyrj7Hc0srkOAfgHwX+i2Zb0Kf4bxoVvgIc0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Xo6Xyd9QX9DRnkIOkGtaDVKtL4srGAiS30gsUc9vBnhFymjMSEs/mPEftcUkLhRrY HDGkDWEENrkXoZoi0Sp9Q135KHp8bqnIUMKvq5Uv4VRPDThFvumZleEgapAQm64Ymx mPqgTclKgH7RBhb9tcZ7dAc3Q5WTqQ4ZX669Pz9c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hangyu Hua , Marc Kleine-Budde Subject: [PATCH 5.15 079/913] can: usb_8dev: usb_8dev_start_xmit(): fix double dev_kfree_skb() in error path Date: Tue, 5 Apr 2022 09:19:01 +0200 Message-Id: <20220405070342.191836700@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hangyu Hua commit 3d3925ff6433f98992685a9679613a2cc97f3ce2 upstream. There is no need to call dev_kfree_skb() when usb_submit_urb() fails because can_put_echo_skb() deletes original skb and can_free_echo_skb() deletes the cloned skb. Fixes: 0024d8ad1639 ("can: usb_8dev: Add support for USB2CAN interface from 8 devices") Link: https://lore.kernel.org/all/20220311080614.45229-1-hbh25y@gmail.com Cc: stable@vger.kernel.org Signed-off-by: Hangyu Hua Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/usb/usb_8dev.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) --- a/drivers/net/can/usb/usb_8dev.c +++ b/drivers/net/can/usb/usb_8dev.c @@ -670,9 +670,20 @@ static netdev_tx_t usb_8dev_start_xmit(s atomic_inc(&priv->active_tx_urbs); err = usb_submit_urb(urb, GFP_ATOMIC); - if (unlikely(err)) - goto failed; - else if (atomic_read(&priv->active_tx_urbs) >= MAX_TX_URBS) + if (unlikely(err)) { + can_free_echo_skb(netdev, context->echo_index, NULL); + + usb_unanchor_urb(urb); + usb_free_coherent(priv->udev, size, buf, urb->transfer_dma); + + atomic_dec(&priv->active_tx_urbs); + + if (err == -ENODEV) + netif_device_detach(netdev); + else + netdev_warn(netdev, "failed tx_urb %d\n", err); + stats->tx_dropped++; + } else if (atomic_read(&priv->active_tx_urbs) >= MAX_TX_URBS) /* Slow down tx path */ netif_stop_queue(netdev); @@ -691,19 +702,6 @@ nofreecontext: return NETDEV_TX_BUSY; -failed: - can_free_echo_skb(netdev, context->echo_index, NULL); - - usb_unanchor_urb(urb); - usb_free_coherent(priv->udev, size, buf, urb->transfer_dma); - - atomic_dec(&priv->active_tx_urbs); - - if (err == -ENODEV) - netif_device_detach(netdev); - else - netdev_warn(netdev, "failed tx_urb %d\n", err); - nomembuf: usb_free_urb(urb);