Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1069124ybl; Wed, 14 Aug 2019 10:12:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTnuYV2BW17RLmlxqMKVhxO4peENlWFUFXr8be8aJ7YQcjH41K0+2zHNAET9C6bwFstYzm X-Received: by 2002:a63:eb06:: with SMTP id t6mr185018pgh.107.1565802720081; Wed, 14 Aug 2019 10:12:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802720; cv=none; d=google.com; s=arc-20160816; b=IAwuTdiJvynNXcUX66tOG8VqqrqkGx+puHCu1jGN6NDR+Rd7+H7dy+9/varXS8H8jG rkLtiyht+96IYP2/I6Y9/3NDkrZLtQ4isRhF7bjpEHS78QeCMzhFBRzfcfzkJakzmE2D dRVWHRZ4ctpRE8YhF5sUWYtp0+eesHQc3/SyJ9jcrhV4/mM1FMAWoZ7Ou7jRhuF7o7Cs AXyE5nMnHavPQ0D8UXg3EWYAaFY1QwE31+YqmGnqtC9a9ICkBVtE/XQXtMyVPHtFo4Bk HyNXx4DMVrM3OpPHVBrN2nmz5imdVpLXU8YZ02Q3wdYXeddseiQNvUIAyWMkWd3DJiX2 3r2w== 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=qKaz0qgciDasGuARY7qKU54Bqd+6ER+wn3OtGEgG86U=; b=B+poG6VWpE7V5Xjwd/BNDQwgIQMv7hW+GNTxllwaxOb+8XdA1NCLFnKiiaANMUs1pV Dmf3Oxw5MINdDrC8lnoJktqn6YJVqTRzgU9R1pqvGzxiIjKSpSVQVVi53iEwBKWOebwA oBXOUefDsQ3tqA8FpqTRJQyTpN/fcPJdK19sVrgGACgQFa9P+W/iZF/RN+Jb413+IUzA +k0lThnmaRIwZ/8UeIrdWuKlqcsbhSsd1k8iyP6zJes7U3jzhPvaleL+//3Ftpl/+J+T 4TRjjG8HA/zFRcrNKrMSzI/q1BuNjymsEOQW+InBKTFbPKeQ6FFWMIpfCLLUVFXr84Ip moIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JHUL0A3U; 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 n12si159883pgi.550.2019.08.14.10.11.44; Wed, 14 Aug 2019 10:12:00 -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=JHUL0A3U; 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 S1729621AbfHNRJg (ORCPT + 99 others); Wed, 14 Aug 2019 13:09:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:59968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729744AbfHNRJd (ORCPT ); Wed, 14 Aug 2019 13:09:33 -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 AFD472133F; Wed, 14 Aug 2019 17:09:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802572; bh=OPx45xy2p1rWXhmJFLkvQZHWulh+StboAdUlXNpnCFg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JHUL0A3U8GBWnJDVgpYJ88QhCrTWF/F/WnBOdppSNjsDk4lmA6FkaJyUMff2BpOXK MsW2qksZsShGvFsRMbffJwP3TclfEnMfpJXZr3axof7jNYEzFqlLP7uEEyQ3ObWzc9 Zn+uNs0mQJ0Trzi8RBRu7kKb/CAvD6M4Oukthrc4= 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.19 32/91] can: peak_usb: fix potential double kfree_skb() Date: Wed, 14 Aug 2019 19:00:55 +0200 Message-Id: <20190814165751.055919064@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@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 @@ -576,16 +576,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);