Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp622742ybh; Wed, 15 Jul 2020 10:43:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyLLOJCSqRaXceq+IOX0GDr7NJ1XIijZfBTJ/8FYrNiC6d5UEEG3ZN23xr3IUWdGkc9yun X-Received: by 2002:a05:6402:377:: with SMTP id s23mr760339edw.200.1594835037699; Wed, 15 Jul 2020 10:43:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594835037; cv=none; d=google.com; s=arc-20160816; b=M86hD7/T1El7yimiuXqeDsUxjnVY5PUfnkjiAqCTdYBjFXqSvARkQcmgHZ+34MPmuK xF+gKt85YVN8QH8IXYjEDqLP8l1nIryKrNOIORCqzM63JUJp90GRA/0knvhSfP3YeVrG hLm3eRIAeWY6lA6TEf2mAn7qdQgDTHmRO0A/7HgTAMBK6T6db1Nr+mD6OkS7iHNJr0pw JMcU2xvT9opYx3RnCnho/cRG2jv+CXmTutpg0OBG0UtrQwilgMlAJP78F20BblotisF6 yW2TL2K39VZum3Lv7XJWDtdGteU/Lu3yRPE6I86eQs4KLdTC4lq9JQSPlYv+QnJcJvth wGsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=TN1IJMQQ46HiqWTYBvVUnq4EMwJndD8JhUy8i6D0BcM=; b=K5Vtv8kM0HGgpjO82BVfCJ8FjZo7vXEl9wgY+dIyWy/5KIb4SGhAJuu9W1dyeto36X HrIiRlOEzmqvWp2z7A5+CWuDfglmF2hM2Kr0NTeeEE2M4etF1B9UxgJEGO5Yttrx7bYO NRHoI3NM4wXg3AMjNndilLTFkprUMUDdwX+Fr0ZErb79yjaStg8J9ObnZ5iKPZaNmujp IOF3fHoDfpM/fIvcqLAKFEf2XuzWTfS10DResSSgLP1ZzVW1Hv1apguMkaqNjXsxAa1m 2EPZDBIMTPna4m5qzSmTBwIlozqzL1aJtjZqbGcxSO8tVPHPEEkmK0+43LzNfcYtqOnU P/Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pks.im header.s=fm1 header.b=Uuj0l0Os; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="S2WOEQy/"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id va1si1617294ejb.558.2020.07.15.10.43.22; Wed, 15 Jul 2020 10:43:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@pks.im header.s=fm1 header.b=Uuj0l0Os; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b="S2WOEQy/"; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbgGORmu (ORCPT + 99 others); Wed, 15 Jul 2020 13:42:50 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:60933 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725861AbgGORmt (ORCPT ); Wed, 15 Jul 2020 13:42:49 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id EA4875C00B0; Wed, 15 Jul 2020 13:42:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Wed, 15 Jul 2020 13:42:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=TN1IJMQQ46HiqWTYBvVUnq4EMwJ ndD8JhUy8i6D0BcM=; b=Uuj0l0Osoe2YhvGcaDY28ahp/25GdTrq9QA3OmIKC3/ GcAlqmdurAtp1DipmdOyCT88TrCXfqD1A5FZ12NCdPAaxTw9ghPtWDAoQv9ODhXM FOSH73UE4WKZNzDtplg3zbdsQaB4Unz/tU+imiFXQrWc9BaCZeSVwAv8uVclmo0b SCucYbgYKLMDVRm4DiSAa3c1dB1IH9DmNie8YERHgZungF8udAiJrY/scR4x9opy YtJ+PLhOYLn4ZCNA4/gFpwBC2esDwsS6l5D/vdvz5J398JKSsUnEqzdZfd62vgS2 6uiH+pEfdBB/9b9m/G3BgmyYaoHg3ODQo9weRtdcPNw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=TN1IJM QQ46HiqWTYBvVUnq4EMwJndD8JhUy8i6D0BcM=; b=S2WOEQy/mPQsf1N5W1dq+E bb0GwMKa7s66gnoPTx07lyINu0F2EDVKpfK3p/GcaJO1kNHW7UiCvFPk7bWvvpC0 v8iHmCicXlW4PLkwcBHUyOeN8nyoyplrCSr7NIeEWVGq6mln2F22iZbBHfl6npFU WAAeWkBLB/raaPjzSVRPxPZHnkxF/+i1D5fEPk4QXEW78Kmj10RKtPQIW3dTXAbK ZEJtCvpQdbl6FzusjDkeS9VLg98QuimWZptm5C7ugK3aMLljWCwNUcLeZS4Yu+Hc pxvdi5gAaLtLQmufvxlb0uk7wyfFDFiN4qPiIj0+0Zuc6UrO1sDLb8bAZ5x8oHnw == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrfedvgdduvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrghtrhhi tghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrh hnpeehgefhtdefueffheekgfffudelffejtdfhvdejkedthfehvdelgfetgfdvtedthfen ucfkphepjeekrdehhedrgeekrdefudenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehpshesphhkshdrihhm X-ME-Proxy: Received: from vm-mail.pks.im (x4e37301f.dyn.telefonica.de [78.55.48.31]) by mail.messagingengine.com (Postfix) with ESMTPA id B80EB30600A6; Wed, 15 Jul 2020 13:42:47 -0400 (EDT) Received: from localhost (ncase [10.192.0.11]) by vm-mail.pks.im (OpenSMTPD) with ESMTPSA id 0ae5c766 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 15 Jul 2020 17:42:44 +0000 (UTC) Date: Wed, 15 Jul 2020 19:43:33 +0200 From: Patrick Steinhardt To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Subject: [PATCH v2] Bluetooth: Fix update of connection state in `hci_encrypt_cfm` Message-ID: <50fd2c75ce196196f879f8373555cc30bfc75154.1594834970.git.ps@pks.im> References: <0df5bf3eac160de28b9493a8959510980a8a8e8b.1594803508.git.ps@pks.im> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="XOIedfhf+7KOe/yw" Content-Disposition: inline In-Reply-To: <0df5bf3eac160de28b9493a8959510980a8a8e8b.1594803508.git.ps@pks.im> Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --XOIedfhf+7KOe/yw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Starting with the upgrade to v5.8-rc3, I've noticed I wasn't able to connect to my Bluetooth headset properly anymore. While connecting to the device would eventually succeed, bluetoothd seemed to be confused about the current connection state where the state was flapping hence and forth. Bisecting this issue led to commit 3ca44c16b0dc (Bluetooth: Consolidate encryption handling in hci_encrypt_cfm, 2020-05-19), which refactored `hci_encrypt_cfm` to also handle updating the connection state. The commit in question changed the code to call `hci_connect_cfm` inside `hci_encrypt_cfm` and to change the connection state. But with the conversion, we now only update the connection state if a status was set already. In fact, the reverse should be true: the status should be updated if no status is yet set. So let's fix the isuse by reversing the condition. Fixes: 3ca44c16b0dc ("Bluetooth: Consolidate encryption handling in hci_enc= rypt_cfm") Signed-off-by: Patrick Steinhardt --- include/net/bluetooth/hci_core.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_c= ore.h index cdd4f1db8670..da3728871e85 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -1387,7 +1387,7 @@ static inline void hci_encrypt_cfm(struct hci_conn *c= onn, __u8 status) __u8 encrypt; =20 if (conn->state =3D=3D BT_CONFIG) { - if (status) + if (!status) conn->state =3D BT_CONNECTED; =20 hci_connect_cfm(conn, status); --=20 2.27.0 --XOIedfhf+7KOe/yw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEF9hrgiFbCdvenl/rVbJhu7ckPpQFAl8PQEQACgkQVbJhu7ck PpS16g//UnlOVdhsGJy5NF7MOvpKO40nLapdxOc5qvJX37rTLkyE8GTfCKpkrHBf XxJ1DOZWLOhqEEb0RX32L/JjuOCb+wUjAwx6+y6o7vXswFKUxxUlHRxHOGDafq6n eD5NPcw9Lv1dSLvMzNfKVdD/hVgf1wy8Uj92SREcSob8Yzu48nrcovRYGHumhJ49 dg2XJ2a0UpnAxuwjPzcp87rChHCaAYb67yBrWokURVp34QHxjiBt4jM8hERMyD2O BBXiJb7aODo3Wa4BFTZcHMBGraEjpgsrDe1tURBnkrn2MxaAawigwNnz4Q+KJS0S dFUoOuhrcuNgzUGBNiY0efW7SbZ9pFO09hmCgcylb0TCxX28kpOfHX98ruxfdRbz Z/5ayYtmQNQVQojY8TWpz8hoeLArMC8sfrK5eP6B0lpouiDBUVh+LTBrCchs+3Hv OLe7HazD6pPPI6zX2uxLhbSzHld8aC9n088NUlwijCMENRXI30uQIYYioh2vJLsf natq/0YZbWety2hJL1sTp6Ai0lXVpZ2yGyrI6CK+WA8J6GH7Y9Q/JJHCFHr7vcAo 5nlM9gMB4I0Hrww+DlRjFSepX7vhnZz0agD02JWQEgseEtT2cEIJz4PUg12bTvem oe/ZHzjXUm8oKm5GI/7Z/sUEgzC77Et/IOjeyThNUkCQ3pyP7l4= =U4vV -----END PGP SIGNATURE----- --XOIedfhf+7KOe/yw--