Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1077686ybl; Wed, 14 Aug 2019 10:19:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjzpNO3j0hwWuVgkuFgpolyxmX+eCEqrMYqP6o20yJaauRDf4inuNosFwR7r6UEwKN6hmv X-Received: by 2002:a17:902:7c8a:: with SMTP id y10mr436506pll.65.1565803187992; Wed, 14 Aug 2019 10:19:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803187; cv=none; d=google.com; s=arc-20160816; b=LPFiwJ53cQa2eUYINTYg14ggM5I3h4yWt5UmVeJsrX/h/n2zap2l3g0IoE9CDd9nXU KUNkBrb9uMconO69iNfjH1XU6Z40nPBP1FtX9nvb6LzRrnkQs9Rn3dKmyiUhqdFE+lYy WH/TMdhjFH0XI2abqPrxDl0kxJk7Vy+pMSfgl6y1LYhCznxmQ3szuauzjs+M11fVnjlS uHbdPYvdOx/VSzkXnNNWJPDyqI4JOob/svMTshIPBLB3Oeh1oVzYPMxhaWJiRs0OY5HF PDjjLwhMt68qRBRT98d+GpOrBnIH8IzRlNXD5TgLEm1RWX2n/M400VymsVvyhJwsoItF YuWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UrdhA3H5jO4DuNUD6uOHAzgg6Cw7lS/wjrIFkmA7Gts=; b=RSVTPu2E+k1KtriEiEQTInHqGPGpmhQzPwMkulpH9oJtLsRv/YjxhcBuZQVpvQgDUG S/lXLzXSgf16aTfwMxrW4nPqZmT84eF1zqiXaJFhabji+Y+Tx+y+/QT2O06EDqzfla3x B8kjlI4h0xWXbPZoNRlZkXuj3qWLvZiTxtiUi2cbEPrPWhAJm5rUX/Wq+8+yEeviJJrh ACIhyx/IzeUwhFKLy9EqJBAYnuFVDfAXqCrwqcmLogfIYArr5TN3Yfc7quhSHg5xNuyT kjan+TFrmEqc7bgtPWRMAJ+EJoDmKOvKlOmcsP14bnDIjhHgUt47oHCOrfH+yVw5Ye5P oSbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oaHW9v0U; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i188si68366pfe.96.2019.08.14.10.19.32; Wed, 14 Aug 2019 10:19:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oaHW9v0U; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730225AbfHNRNG (ORCPT + 99 others); Wed, 14 Aug 2019 13:13:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:37208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730817AbfHNRND (ORCPT ); Wed, 14 Aug 2019 13:13:03 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9393B2063F; Wed, 14 Aug 2019 17:13:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802782; bh=8xpq1kUpLr93vF53RBiQDurISld0SNEozVxZw8bXAiA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oaHW9v0U3rWgngZ6jwuthAOKwsECD1xCrDASspalJo8Ep/sKsYg/Fog8+bh8GXJZ0 x59aj+ry7gmLPGjQDCoesRqDEABJDmaFptz4BI1+Oc7yu/0HBKmHWEhagAXDSHqJn/ 1HG3/GzCWOgdnp2jwGl64/6PJ0/VYHF0a2J6xoNU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephane Grosjean , Marc Kleine-Budde Subject: [PATCH 4.14 24/69] can: peak_usb: fix potential double kfree_skb() Date: Wed, 14 Aug 2019 19:01:22 +0200 Message-Id: <20190814165747.121465841@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165744.822314328@linuxfoundation.org> References: <20190814165744.822314328@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Stephane Grosjean commit fee6a8923ae0d318a7f7950c6c6c28a96cea099b upstream. When closing the CAN device while tx skbs are inflight, echo skb could be released twice. By calling close_candev() before unlinking all pending tx urbs, then the internal echo_skb[] array is fully and correctly cleared before the USB write callback and, therefore, can_get_echo_skb() are called, for each aborted URB. Fixes: bb4785551f64 ("can: usb: PEAK-System Technik USB adapters driver core") Signed-off-by: Stephane Grosjean Cc: linux-stable Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/usb/peak_usb/pcan_usb_core.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/net/can/usb/peak_usb/pcan_usb_core.c +++ b/drivers/net/can/usb/peak_usb/pcan_usb_core.c @@ -594,16 +594,16 @@ static int peak_usb_ndo_stop(struct net_ dev->state &= ~PCAN_USB_STATE_STARTED; netif_stop_queue(netdev); + close_candev(netdev); + + dev->can.state = CAN_STATE_STOPPED; + /* unlink all pending urbs and free used memory */ peak_usb_unlink_all_urbs(dev); if (dev->adapter->dev_stop) dev->adapter->dev_stop(dev); - close_candev(netdev); - - dev->can.state = CAN_STATE_STOPPED; - /* can set bus off now */ if (dev->adapter->dev_set_bus) { int err = dev->adapter->dev_set_bus(dev, 0);