From patchwork Sat Oct 22 07:18:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7154 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1087955wrr; Sat, 22 Oct 2022 00:38:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4N7OYrU7RwwTigF+VmVtb+P3aRPDG9ZIsZ7ot7JqC8J+wA5knAg0yHoB9hqrS08Jr98d5F X-Received: by 2002:aa7:d4d9:0:b0:45c:7eae:d8d8 with SMTP id t25-20020aa7d4d9000000b0045c7eaed8d8mr21260074edr.254.1666424298653; Sat, 22 Oct 2022 00:38:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424298; cv=none; d=google.com; s=arc-20160816; b=WwrJoj3T/Gw7kHSqZ0TNQOb1XsZocpVSICNXeMITLAEr8uqHBSlmsLlIWofWzy2N6m TP5CvMFVgUVaVhxyDyO1XfayvbGsqOCmJvGKDOHjdfKSpRwBI5wmvu4dkdKnA+e+n+m2 sPkYYnzFc8A4SxjqVasHjVAV5WMPO/AjcaUi9995DfQeODa99HhjRcOe+p3Y7peud6I+ Lgdwb4xU3Mu1HkqdxeKNBRLhPFAZXM11cxk/vRCIIxTAKWlxO9WPMHrViSMc88QnAWdd /TXeOee6fI6iNL5y/hu8AMyqsaaCHmVv/Hy0B7bV4T6UhF76g9UFV6gknaAlvI3z4mou oUZw== 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=x7m1HZNmkdebieyzcDaH9/r7YeOcC8p7Wq5oIqcb25M=; b=uvXPh/8Vd0PCvrjnZo1ATJB1dtyFDdOD1k8pOvuqP9/eAOwAjpv4NjuWH+lhTlxGYh SjTtqITwXb5YBSefqrr5C6DU2VMCm0I4MXovj+xlIqHBfzBz4Jifkzs/sn3hR3tBywFo /jJsCHoIWAC9KH4lx0W4gTLkZGNfg4q1/2MNP1mOVKeuoVZkQ4guBMcugikQ9q6mHFvQ WD4CsLqwMneTSNmv+lWqz0efbHKDFSzMTOaGfuGrKUFT5dBYzZVAWQ8R/rJqyENQbE2p qP4+GH/oDguJ2qU1QzsN1wVK2lbq+A62JOZsDVvKqHuMI9O7TSG6hfhwZlrPu9HUK7Sb 4PZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Hll0OjoL; 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 dp20-20020a170906c15400b0073da0ce043csi24235495ejc.619.2022.10.22.00.37.55; Sat, 22 Oct 2022 00:38:18 -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=Hll0OjoL; 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 S230248AbiJVHgy (ORCPT + 99 others); Sat, 22 Oct 2022 03:36:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230164AbiJVHgO (ORCPT ); Sat, 22 Oct 2022 03:36:14 -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 80B256F24E; Sat, 22 Oct 2022 00:35:03 -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 99A7E60A5C; Sat, 22 Oct 2022 07:35:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A058DC433C1; Sat, 22 Oct 2022 07:35:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424102; bh=kPlLgIU4K3Nj0h9buGsIm0radl9uI7/hOyIa4w0HL+s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hll0OjoL4Ehtjj7W01ETAPYFpF33Ij4u4XIG2Yc8N4az7UEyt5+goz65aHwx93rsC 63XnUCbVqwf6B6TGlmUEsYd3UhH2qG56C1Nh8pQQLTHDDiArxasAAcWL2p8c5G+DAr F5W+dHFhlvEcvysGDOlWenqNDYLiRsvfrXtTWdFs= 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.19 028/717] can: kvaser_usb: Fix use of uninitialized completion Date: Sat, 22 Oct 2022 09:18:27 +0200 Message-Id: <20221022072420.061082568@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747372525496511858?= X-GMAIL-MSGID: =?utf-8?q?1747372525496511858?= 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 @@ -712,6 +712,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 @@ -1914,7 +1914,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);