From patchwork Mon Oct 24 11:28:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8853 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp432972wru; Mon, 24 Oct 2022 05:48:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6VgozyKymywkAL9ApdgDFaq2yN2NDt2S0fikFbwzX7+dAxM0sw82/cVqT4cYPUdrgWaPcr X-Received: by 2002:a17:902:f78a:b0:184:f2e2:a5fa with SMTP id q10-20020a170902f78a00b00184f2e2a5famr33577515pln.161.1666615693137; Mon, 24 Oct 2022 05:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615693; cv=none; d=google.com; s=arc-20160816; b=nz0p/i843uU/Bbuy7oT54WCJh+Gmn9Sr+IkwAa/5V5KEUOBbAaQ3lpDmvQQqFH/7kk xDt8HiK38AWTP6bvmJ4AEzTZCmYwGrKOOVMuLJXPwx2nBHz3E1NcXDQEgzkvyoOHlrM/ E5eJXlQD9RBrlOuyo+wDbrwvzolhgr23Sifb0CzBtVvrTUefWFsN3SL4/LCkKauK/Lff 5ax7TP9Xx82c8Lto4DB6wr/AkjFynyZnALOoQXoz00dab3p+vwmltHgf3kBwpSZDyV2R dkWsqkUJyxd9aNYl61lzLqiHkSEGY8kWsa6pRG1NFwqGf7xhzA0MPn4jgE1Es+41Jysf o2pA== 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=Qltv69vruinrOl4jMgcR8YUqzf8Tx/eu8R+mN01JZf7y/+aNpeDNnb+xPeIaLUmz51 A7GBqC4yNtnzU2rmw1zftIFu7dpvKSeoAZszQSehARsj3SvuNHe6lI2fzYPiYB0bTUJ8 zePicXKlWcSK7wHDJj4wMZOI/qXGOaYJ7kwuDU4HqyEiWcrZTzt3MYjtRd575wR1QIpS eHewKl50Dind0Gu2bggergVjvMMk3edS9zjOdG69jyyN+waJuvIHI/p0YeordazeYb6y pv8F4+BcYrA+S77unzAIoirF+Nkv5gQ5jsfWEunL9oB7TSwE83w2KJJ7whksfCczgLWr 5ugA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Dn6lxCak; 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 z188-20020a6333c5000000b0043882f3e74bsi35583181pgz.441.2022.10.24.05.47.59; Mon, 24 Oct 2022 05:48:13 -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=Dn6lxCak; 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 S234140AbiJXMjI (ORCPT + 99 others); Mon, 24 Oct 2022 08:39:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234687AbiJXMfn (ORCPT ); Mon, 24 Oct 2022 08:35:43 -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 5B7A2356E4; Mon, 24 Oct 2022 05:05:45 -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 C8A8F612D4; Mon, 24 Oct 2022 12:05:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8CE8C433C1; Mon, 24 Oct 2022 12:05:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613119; bh=BFat5BEfy41jcfjN1LQSScF9bLmYMpIuSmHtawi1W2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dn6lxCakEg6uASYIXyVpP/I6uq7CIElvHrQD6ODfRLKCnEklWrmQygSkIHo+VcKJZ Cfnu0xrSY0IVFZS3p2uo3xzeRIlFF9R7snHY0zKI1kIbIwiyAHbnmYjKFtOKmEvXP0 E6ykY9wTmCaKn7Zsf4Znaazn82So4FmwCzLE8k30= 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.4 016/255] can: kvaser_usb: Fix use of uninitialized completion Date: Mon, 24 Oct 2022 13:28:46 +0200 Message-Id: <20221024113002.973471295@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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?1747573217151722241?= X-GMAIL-MSGID: =?utf-8?q?1747573217151722241?= 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);