Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4734233iob; Sun, 8 May 2022 23:40:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAP1FXvD4OWAKeSshVoJ+924Xc5bvDA354oyDhW7g88f2qYruFDU0ATd5qiuk8eZGJKF+t X-Received: by 2002:a17:90b:4a41:b0:1dc:1342:e584 with SMTP id lb1-20020a17090b4a4100b001dc1342e584mr16660909pjb.179.1652078419893; Sun, 08 May 2022 23:40:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652078419; cv=none; d=google.com; s=arc-20160816; b=vaiYDpaiTEx4kYOgwLDZhYeUE0u9E34sYXVrDjGif1f7LMsALx5qO5Ta/z78VAPwAg 0gd/dSDXUX0m6z57RBrE7zDfv/+qBnsT98DmChVH+rFF0rAirjxE+fICOPgftDlTFsuJ EGQWvg5jTZOt4+HBMQeOmss7Pa7+O+mTnrhNjmbX7Q5IGU/BRuS4Aepnct9BXca5096B 9EUfTMjTV90NYrX0kihW2yX3q+SxKra5PArhhsp7iQgzJ+bEpzPrgoKBO1Bwjh3zyoDg KVE6jB8uZIs8IpvZ8/UdrNVOdwt0BaZDUjACu+3svj/87NW0aj6ZHDz7SkrwsBvKvJog Xcew== 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=REgckmI7l8T6TIH5VE3fzR+omPweUtDWh+xIWUL/SzQ=; b=NlXn0c88jq13IE9xT0PRgsNfVIZXVY5eD753vvjbuYHxqZqwQthstDw3dFS/YDIAZd DqFEIhw4ps4kHm8/voEA4T/4DJqGqesMqP70xHm31Pdpmbi9TUHN9tlJkXxU0qh8sW7C VX81uaH1Vdng+AV3KIX2MBCwn3uB4iRQksvaugg7II+vYz2GEQEVmUT7sK3LcNgmWPq3 1Rjz50uErn+dJ4ZZeB++u+omMyiP8h7Al205zkuAes7oYHFEtOuoyCGMFaQr8RTU31B4 f4apEhbQV/I2viYhWHwzKsRc1jBbRxKnl/6DslPcxHfj/Aeuhy9E/2d+p155Hyy3L0kA 7pPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kNdKtSC0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id u74-20020a63794d000000b003aa6755ff79si13441576pgc.398.2022.05.08.23.40.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 23:40:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kNdKtSC0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7909214D7BD; Sun, 8 May 2022 23:37:23 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357337AbiEDRO7 (ORCPT + 99 others); Wed, 4 May 2022 13:14:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355201AbiEDREM (ORCPT ); Wed, 4 May 2022 13:04:12 -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 2BF014E3B8; Wed, 4 May 2022 09:52:49 -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 CA701B827AB; Wed, 4 May 2022 16:52:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 760E2C385A4; Wed, 4 May 2022 16:52:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683166; bh=j9fGvGTJIWWMls+EO3uh4k7EJ/UNIJzX+68+UCC0GGE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kNdKtSC0SNjgUlQNLdHQRrNY/ThtkecunJKHD+XoIzaiF4RqAhP0C+RaWynAfMgef efObYVY2Zr44M52OCn1FyZnxYLXGYESQl/T5lIIGJlsBdhlfIjncWsIgQIzwyepxL8 HpVvZwmxlMnISjycnht5W+L6cRWBXh6mYT6ws8YE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Heikki Krogerus , Jack Pham Subject: [PATCH 5.15 018/177] usb: typec: ucsi: Fix reuse of completion structure Date: Wed, 4 May 2022 18:43:31 +0200 Message-Id: <20220504153054.996787420@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Heikki Krogerus commit e25adcca917d7e4cdc1dc6444d0692ffda7594bf upstream. The role swapping completion variable is reused, so it needs to be reinitialised every time. Otherwise it will be marked as done after the first time it's used and completing immediately. Link: https://lore.kernel.org/linux-usb/20220325203959.GA19752@jackp-linux.qualcomm.com/ Fixes: 6df475f804e6 ("usb: typec: ucsi: Start using struct typec_operations") Cc: stable@vger.kernel.org Reported-and-suggested-by: Jack Pham Signed-off-by: Heikki Krogerus Link: https://lore.kernel.org/r/20220405134824.68067-2-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/usb/typec/ucsi/ucsi.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -955,6 +955,8 @@ static int ucsi_dr_swap(struct typec_por role == TYPEC_HOST)) goto out_unlock; + reinit_completion(&con->complete); + command = UCSI_SET_UOR | UCSI_CONNECTOR_NUMBER(con->num); command |= UCSI_SET_UOR_ROLE(role); command |= UCSI_SET_UOR_ACCEPT_ROLE_SWAPS; @@ -991,6 +993,8 @@ static int ucsi_pr_swap(struct typec_por if (cur_role == role) goto out_unlock; + reinit_completion(&con->complete); + command = UCSI_SET_PDR | UCSI_CONNECTOR_NUMBER(con->num); command |= UCSI_SET_PDR_ROLE(role); command |= UCSI_SET_PDR_ACCEPT_ROLE_SWAPS;