From patchwork Mon Oct 24 11:26:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9016 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp441273wru; Mon, 24 Oct 2022 06:05:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4dWFNo6FigfV7PrmvhtnoQBTfCm225vCbPaz0WdUBLohFUj/+kVZSPx5WMPIKrjy6WjZW/ X-Received: by 2002:a17:902:6bc9:b0:186:878d:3c with SMTP id m9-20020a1709026bc900b00186878d003cmr14161014plt.72.1666616739830; Mon, 24 Oct 2022 06:05:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616739; cv=none; d=google.com; s=arc-20160816; b=QCgtcT41+bd2n0J4BRuxN/HbyQ/8WAyd4UaWiZaAnnBjhBkivPC1j7gI76i63/jmP8 1cT2tjjVWu/Q36v3iujepddi2Ew8Whn/7mei5EwzxRSLTt+ZQpvBxHhTlxcdY26kiBXZ zHsaIIevNwn/aUvCwbucnF57YitFbH/CTK25R8rmizH7GsWvzpxpMZUhsFKjLrJ1vDFE ziPKLw41Ws2uQQ9dVgDWgLaGCODehXyaI1Gc7eTFDLQhv8XjgM3ha2Se1TLTtr8LgnKj PHNvHniciNe+lmJgLJSIeinws7StTuSTlCQyaVVSaZsXWNm7fzBfyP442etD0LyZ+jlJ EH/Q== 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=uupszNGThibcuoV0lCdr6FdGwKbohbo2rPAHpTTSjgI=; b=nAdMof+bDa58E9xqn3UcIHW2sP7IaXPUjjHoQDz3fZ/dQNJOiyruJ/ozTUUdKy2l0g SFkR34kr1u+OefxdcCgdDglliehm+QO9DBw5J7gJigqpJfpFu6RORDTCxaand5r6Q5Gh hXV4w4o47SGPzHE5kwT2YK3t9srXWvGisSrVDqnDo/oofC1nIc+r2s1boEfmiAC4M826 qwKA4oMibbS5zhsoxbpb0pdXO/fxVq6t4MOLCnxKonu2JPiNOzuasxoRY/C003yZks3A f2CFgSwx5yFUu08YwD6AOiqPJqE6N44ryC2jvVcSn6eHUGJlIQbKOKBq1QJyeZI7Rejr EZ2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ziItpBwN; 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 qe10-20020a17090b4f8a00b00213245b0b4csi1295103pjb.171.2022.10.24.06.05.18; Mon, 24 Oct 2022 06:05:39 -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=ziItpBwN; 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 S235386AbiJXNEl (ORCPT + 99 others); Mon, 24 Oct 2022 09:04:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234966AbiJXNAr (ORCPT ); Mon, 24 Oct 2022 09:00:47 -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 04B201A811; Mon, 24 Oct 2022 05:19:41 -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 121B461328; Mon, 24 Oct 2022 12:17:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23500C433D6; Mon, 24 Oct 2022 12:17:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613871; bh=BFat5BEfy41jcfjN1LQSScF9bLmYMpIuSmHtawi1W2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ziItpBwNfvpYgPx5FVsDo8xcc0RMNkFRbfs7hI9H3s76W0QpBLTPIi9IKPcGNTyPC j7U3g+CpuEfY9fS+ourMylc6f/yPu4Eng61g0Kzgudp6xTCk04wGd0Gid7KkDOKODK emPyA9inrSmQU7cotJuDNQ/UUvdZa1aDJVqRTPoI= 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 5.10 018/390] can: kvaser_usb: Fix use of uninitialized completion Date: Mon, 24 Oct 2022 13:26:55 +0200 Message-Id: <20221024113023.328176062@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 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?1747574314209353697?= X-GMAIL-MSGID: =?utf-8?q?1747574314209353697?= 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 @@ -690,6 +690,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 @@ -1886,7 +1886,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);