From patchwork Mon Oct 24 11:29:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8752 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp430105wru; Mon, 24 Oct 2022 05:40:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM45SGSkfL8UieTBzKsEFSISD6IH4VpmrFwU6BvklRFiOOw5seONc3InOFBDjinN7ondYCTk X-Received: by 2002:a63:5164:0:b0:43b:e57c:a15f with SMTP id r36-20020a635164000000b0043be57ca15fmr27659698pgl.586.1666615244514; Mon, 24 Oct 2022 05:40:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666615244; cv=none; d=google.com; s=arc-20160816; b=YIhi9/vP3ze3Bkp2DHHkvGNSBZ6adJ8pJ+fmynQSsOjCICDix+vS6LvQ5ZZst2QYRU jMaXUQQ90KK/CMBfI00uOvpOd2Ym74yJOKKpNVH5/vEvwmWMY6fq1GJ1O8u7v1xNKS2G 19NGV2hChEpZOlU1LeMc3tBMka9RFlR4CSPI10gJsgXOcsn11rs8D1j8PiIVtBf4QvlM TiY2bkKDVHyfaQUEqn2+pbHY1dgE3ugiMHWGMj641V5yl8KHY/2m6q49/X7STJIvMIWJ aFcHHFDnbzHE9hSJt/5V0lUgC6/MCM0LUlOj+ngkS1yC0XoXNs1U8UOHQylIinBre1jn 26NQ== 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=dp1v7ZEvCmKBZywwfrj43fzqBkac2yD2T/rlMgipFvk=; b=rngsVv/HhF8jZZLqwjvHtD0LcsJTfDv3dYAmI4vSuUlxxk1ClT43FUGTTr94KovrPe Erc1NUqBKFX6714yriLdlUHjqa5Z00WoB2FDTMrsC69Y4cLZlesYk4hdB+L9snBXZxIq u5GzUOf/z+E/NTJx6RsEtuIWvd24V9A5rIrd3gOL9FngqF7KeAoCzS9j3qMG0wjMr0ib tWzKvKv/B1/VusAXBY8rHvXm1szphH6ARLih2j0g55/T9pBR0BnBfWpPbUuImu0Vfq1z VR/IthI0DVWrQPwijAaj/jjKIW0QE0juZIvUqUO8xowp2zCU4cggg2IL6y3MHDrrcTG7 m+4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oB+v55Wy; 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 l7-20020a654c47000000b0045af77f7f19si36008183pgr.400.2022.10.24.05.40.31; Mon, 24 Oct 2022 05:40:44 -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=oB+v55Wy; 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 S233787AbiJXM2O (ORCPT + 99 others); Mon, 24 Oct 2022 08:28:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233739AbiJXM1G (ORCPT ); Mon, 24 Oct 2022 08:27:06 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 44672857E3; Mon, 24 Oct 2022 05:01:26 -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 ams.source.kernel.org (Postfix) with ESMTPS id 00B6FB811C7; Mon, 24 Oct 2022 11:56:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56448C433D6; Mon, 24 Oct 2022 11:56:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612579; bh=bK95I0MVbjz+H6Bg0timzUZKnQ+EL05ODHzLLISEBds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oB+v55Wyf3S0/sdE3WrYMNDQktG0d6McZyreKHNOhVLJKie/tVPUjKt2SP1C1X3E1 owc0gP4IdkIrMBbpA670iO0T91/HlPkC4T1zZo9WESeB937pHOyEn8I1knz9Zc5nQC nb7BoICLp7hx1d3bTk5bnVLBLViJxufroZTm4Ci0= 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 4.19 040/229] can: kvaser_usb: Fix use of uninitialized completion Date: Mon, 24 Oct 2022 13:29:19 +0200 Message-Id: <20221024113000.393741263@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@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?1747572746176473958?= X-GMAIL-MSGID: =?utf-8?q?1747572746176473958?= 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 @@ -691,6 +691,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);