Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1062740ybl; Wed, 14 Aug 2019 10:06:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkBJ9cn0txlVztUGUZ8kf/3nCKNCCSQ5fzP1CYYm4sRLxx0p9oybIuH5MJkmhCJj4EYZGG X-Received: by 2002:a63:f118:: with SMTP id f24mr192057pgi.322.1565802412579; Wed, 14 Aug 2019 10:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802412; cv=none; d=google.com; s=arc-20160816; b=AQfoPm10sfoukOTpa/pK4si06n8hjEzrJKB9KgPSHImHhnWhs+xWJMzAt7tD93cFwx TrdLwDmZZixbYKKxRV7dOAuTIxMG9lffJL0o+aVGnpAooRV/dFBBV+o5iarN12ZM7NL0 kbw7WJC15yEd0+wHSTFnYJ1zNt50tcd70j+siMPyhM3zbfDYarrK/+Phj9lEamPWJbvs 5OgoOOFJYKImskvOt5Ns3UwWCDiXdBmGZWX9MOCl+vh2n+c5JPFu+Tec+OZJU0nHtzga f7weqJVMLLDDeTmdiVU7SSKRgVWD+rsXzhKXMc41+2SFicm0WRaXXXsOjVkV04SIuTaf s+9Q== 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=c3KV1kMJFSDIh+CczFLDvEGaElP6pvs7n2f0Jp2bVfY=; b=AJHmOgIcb5FW/7d0h3KUPs/uIggJJnPuCEY+aI9jLRrTkhn6SLD1q14hED1ZtxHI3E TRYRXCUeNVZati+85EuRRia+oiJUyyY91rAk62Al+RZdOj/kAx1TPUaT4CZp+R31I0wn jp8dl2rX1kSW045AXVNzsMCzsnooQ68S7+ujhxHl1W9CHQMm2xVJOKeqhacfWHCvNVcw bcfFU83GH4MLADWBmB6MQLZneumoXJyGsFjKo+7LLOqn7gi1GK+BN/r7LpwBJiXYMFdT Gb+dGkHr6oI7UvjlsRwl4hNKZYxgOWfVpOEoVrBAze9Wy6YQp/c4ZJugwrwk4zyBtzNf uARw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bKxc6PqY; 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 x6si169456pgq.473.2019.08.14.10.06.36; Wed, 14 Aug 2019 10:06:52 -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=bKxc6PqY; 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 S1729107AbfHNREC (ORCPT + 99 others); Wed, 14 Aug 2019 13:04:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:52794 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729092AbfHNREB (ORCPT ); Wed, 14 Aug 2019 13:04:01 -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 1D8772084D; Wed, 14 Aug 2019 17:03:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802240; bh=JF5p7eFdyL2uDlvITnkiJ4pO6uUc14BJq2mRocluJ2o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bKxc6PqY7wXzW/LKoEnRsfdWnT6YJIXl2MtmbBh/utNjhuctvSBS57nUSDS5CJP0s f45+ZZAnVp1a4k8sTXNjJBl+It3hSnWwwIvKrgtK8HShoPpSJkONOMs42FSR/8+8Ow 7j737waoRJ8ED/X9cWkVLeodwMxjbm7ucpGDkQnU= 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 5.2 048/144] can: peak_usb: fix potential double kfree_skb() Date: Wed, 14 Aug 2019 19:00:04 +0200 Message-Id: <20190814165801.836883958@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@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 @@ -568,16 +568,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);