From patchwork Wed Oct 19 08:22:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4563 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp204751wrs; Wed, 19 Oct 2022 01:47:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4rTCraU/DzFh/q+/puHZ+RMopm92sd0/ipzxl7enH1tB1ZR6biZG9O7w9HZLJNfR8TvLOG X-Received: by 2002:a17:90b:3ecd:b0:20d:9ddb:f287 with SMTP id rm13-20020a17090b3ecd00b0020d9ddbf287mr39638637pjb.167.1666169230999; Wed, 19 Oct 2022 01:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666169230; cv=none; d=google.com; s=arc-20160816; b=rF3EBwi2zf2B9AoIf+OEgm6XJxUHWPWQzzJ4BY+E5x1Dx0wkMDzklOh8zOWLb2IZTK XRPVbHBILVUvyAQv+1OwGFGA4RkNAbu4F3DjGLOyHB9Z1l+xLy3B9zK565cFiCsIjOxa XC5H69NDJim4S7JotffC3Scf6bQ3BizVGkQFA4xJHBF7Qz9frib3HpQVUMtgcmEMeddI 4HzYE8RGA6sr28fUe/Vme0Ss+Xx/IvjdvZVS5js2q5grbvUhzklD4IuPOvwft/KCuClm zEFzH/OEdGlDId2Xq8A0Www0CgwYfl5ZKc/L3sAAH4D5vCcDcpCP1twG1rG3gTqesCKc zflg== 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=YRTif7NfarZ5Kgl0TnlJeFCWeCCMG1dqPnhKppj9yUI=; b=JV8p5fZ3m3RE+UEi0DwUgAmWYunP7XGV9GxAFw/R9Br/76HGh4Vbvsy5LDMGxMlRZQ 0sqiemVGD56bYEn6E/2ksGgOTj1yWJkdzcVHk4vpqnUDk96wT8XPc06/961kApy+4cj9 AtbNwJCL0XbAMIrsrw4VOlgU7yPI5k4x6LJRWDwXL/bjiXZWls02l+xS768yFrK6FG+Z W12SStYybtIwHpftq4NR5q8eMIc4f2MtkWvxkXWKFsPh2LTxD7hTDHApdjSP+l1F9jVg CEtqM8yUprFm7OUFeBvoadjIdAnf+8QvwZn2/DNXOF9fIZ4PXu6q8xu4kSs8m2JHn6nx CeKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Jg3HzK2l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e63-20020a636942000000b00434ac3b9915si14763928pgc.790.2022.10.19.01.46.57; Wed, 19 Oct 2022 01:47:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Jg3HzK2l; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231524AbiJSIqk (ORCPT + 99 others); Wed, 19 Oct 2022 04:46:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231355AbiJSIpA (ORCPT ); Wed, 19 Oct 2022 04:45:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 142E748CBF; Wed, 19 Oct 2022 01:43:32 -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 dfw.source.kernel.org (Postfix) with ESMTPS id DA81A617AC; Wed, 19 Oct 2022 08:40:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC99EC433D7; Wed, 19 Oct 2022 08:40:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168838; bh=gAPNA266KQeQSGkOEShdOgJZHr8wW5LQFOxSvU+NFec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jg3HzK2lAcQlskLmP6PS/PQr/zYUC+WGl9WhXhwgWGTEbrU4FQ/fAR2+pmdqIf3yv xPH0rDgbQPZ9EwXmLrLW6c9T7nF6+xpVnmnZaL5gpmx2WW9fEL73QlVYCN5VZYaF7f Zp0g8TePHRyi0xDqimVBMfV5G4Y4aWadsCj5CTKc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jimmy Assarsson , Anssi Hannula , Marc Kleine-Budde Subject: [PATCH 6.0 033/862] can: kvaser_usb: Fix use of uninitialized completion Date: Wed, 19 Oct 2022 10:22:00 +0200 Message-Id: <20221019083251.490153394@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747105067835315557?= X-GMAIL-MSGID: =?utf-8?q?1747105067835315557?= From: Anssi Hannula commit cd7f30e174d09a02ca2afa5ef093fb0f0352e0d8 upstream. flush_comp is initialized when CMD_FLUSH_QUEUE is sent to the device and completed when the device sends CMD_FLUSH_QUEUE_RESP. This causes completion of uninitialized completion if the device sends CMD_FLUSH_QUEUE_RESP before CMD_FLUSH_QUEUE is ever sent (e.g. as a response to a flush by a previously bound driver, or a misbehaving device). Fix that by initializing flush_comp in kvaser_usb_init_one() like the other completions. This issue is only triggerable after RX URBs have been set up, i.e. the interface has been opened at least once. Cc: stable@vger.kernel.org Fixes: aec5fb2268b7 ("can: kvaser_usb: Add support for Kvaser USB hydra family") Tested-by: Jimmy Assarsson Signed-off-by: Anssi Hannula Signed-off-by: Jimmy Assarsson Link: https://lore.kernel.org/all/20221010150829.199676-3-extja@kvaser.com Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 1 + drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c @@ -729,6 +729,7 @@ static int kvaser_usb_init_one(struct kv init_usb_anchor(&priv->tx_submitted); init_completion(&priv->start_comp); init_completion(&priv->stop_comp); + init_completion(&priv->flush_comp); priv->can.ctrlmode_supported = 0; priv->dev = dev; --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c @@ -1916,7 +1916,7 @@ static int kvaser_usb_hydra_flush_queue( { int err; - init_completion(&priv->flush_comp); + reinit_completion(&priv->flush_comp); err = kvaser_usb_hydra_send_simple_cmd(priv->dev, CMD_FLUSH_QUEUE, priv->channel);