Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp655169ybh; Wed, 15 Jul 2020 11:36:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNQkZbQmx90TV2e7hNcsLnkKkhetgEfhc5EjR1BLyhbJdF7Khx8AoqkquZMJTUIw9xIA7Y X-Received: by 2002:a50:cd53:: with SMTP id d19mr977448edj.300.1594838202244; Wed, 15 Jul 2020 11:36:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594838202; cv=none; d=google.com; s=arc-20160816; b=AT7TL3XKoS1Y4ZhYK2YVy1LsNqBpi7LSFm7YgX51lwJUXx1Gez5YpuQNG/dnIxWTSc ml9lePt0q5wVuaXlBADxu4taBNr3/Q7giSKppYJ3cpPBeG+eDoOj3Skrny9X4LUONBjt pf8J/0QoFOJkjW/4QOEhc1usIZ7EbkWu9G3EGUihRqxr17nvtrFC80OPvEdSWmmCN4nM tiJ/dPsb+C9TlXeHmAq98ETUQfQVWR1HLDZvS3V6DsUDMjNKJa9W+7czMpwl84nbdgrG 8F0f4nKJSyyxoHUI7vKrPmOr5qhuPGTFD4tgkk0FhOgzsALK5TFHfWvqYVmPNDTMY+ZP AcaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0eqcagrE5c8qsi0gBLE230gaYYz1327tuB+N9Gr+eeY=; b=vyl0R8MjzAluKh66wy0gZ8C9e+/Gc4PXqV7siDN0T3NTvpiNMZ4mBZ0a3gCEfOifQN 60qudm2YJEQMcaJIcPs/R/SZ1GKsNjJqLMYVJ328QeiWeZjzbHZ19R2jYA/ISANw51+I FCVsswwqBLA3KdrWdvITKHOGmADYkepn2n1OE2srPTBRtZkVRixdgpgPPckoyb9yMoPn u0fFnDUK2egrohui+zAXIggY1oJcn8k1ReJvZ1Oy2FS/K+fM+sFrKOSzyg0+zT2s3dzL P5USPH0ggEAyT9aQlG2hf0t1f7RppyHHKU7aw6x/I4Y0da/gS3maHFI3WYCyTmLkRa0N GIaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZHDzb8T6; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q19si1741607eji.315.2020.07.15.11.35.58; Wed, 15 Jul 2020 11:36:42 -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=@gmail.com header.s=20161025 header.b=ZHDzb8T6; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726954AbgGOSfG (ORCPT + 99 others); Wed, 15 Jul 2020 14:35:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726949AbgGOSfF (ORCPT ); Wed, 15 Jul 2020 14:35:05 -0400 Received: from mail-ot1-x343.google.com (mail-ot1-x343.google.com [IPv6:2607:f8b0:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D33ADC061755 for ; Wed, 15 Jul 2020 11:35:05 -0700 (PDT) Received: by mail-ot1-x343.google.com with SMTP id g37so2226191otb.9 for ; Wed, 15 Jul 2020 11:35:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0eqcagrE5c8qsi0gBLE230gaYYz1327tuB+N9Gr+eeY=; b=ZHDzb8T6xX/0jc3o5jbYyiHR47vANcug8kpk09yFHIo566bE3eg2zVo8Yb01KsFLpo Hl/skSTpX8ThWz4SAmYPCz3TGa0dAiJpL1U7S3ONIwtx9SPAj7i45TsAIpbnTfrtrMj0 MUnb4F/4nsUv/OD6PbBaMbp/mLgy9XUt7XBpVB5h84FoYuR2VzYnLaHrsiAijkrGM/HL JIYRYqiG7U6BD9Sa2YKAf/ssHwqhjwjirt0yPkZe9oivt49YghF0UnlvVu6/OS2i+qnR T5QtkjHq/RUIRI62wOWAp68LG+flIYxVLgWdGuYyuAFNszNkN9AwDUDGREw7TDXPs9VG PJtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0eqcagrE5c8qsi0gBLE230gaYYz1327tuB+N9Gr+eeY=; b=oC63PGL0x/JOQxN6MkhLt2XimrmQA4go9vwhU48YZYgmLlXbTqvUxvaA+SHGJMI+w7 I+b/e7RsjcTDo+dxpUdtVp3acaI/UFjTMEK2NOTci9dhEtjnyCG6Wa7Fb8wnHvtntXQO uftG/BX/wog72DrSU2H59nCYuReSTfipEGfR/CtL5Oo/oIluAAHlyJMVsFqWLmd7PaNQ 50KHDaSA3EWwXLevOVGJ+TUSSfz23zZXJxatRDrun+f+k6uivVEU6uaGBtw8yHZAzs8V 8KPnMEzfJ8JSUK7b+dOtolRIj9aTqw+/PkNh71+kVNVV+7hSSMkKTVAC1aHnkm8e9Dug mcbQ== X-Gm-Message-State: AOAM530npZTHIS2U6H99fjzdabC5N9awhYu4P0Yoez/bYJmF06r8Z/RA zwkDumAe4SGBBB/UCWIBSWBRkqvJyH/FqzPLQcU= X-Received: by 2002:a9d:5e18:: with SMTP id d24mr944874oti.88.1594838105141; Wed, 15 Jul 2020 11:35:05 -0700 (PDT) MIME-Version: 1.0 References: <0df5bf3eac160de28b9493a8959510980a8a8e8b.1594803508.git.ps@pks.im> <50fd2c75ce196196f879f8373555cc30bfc75154.1594834970.git.ps@pks.im> In-Reply-To: <50fd2c75ce196196f879f8373555cc30bfc75154.1594834970.git.ps@pks.im> From: Luiz Augusto von Dentz Date: Wed, 15 Jul 2020 11:34:53 -0700 Message-ID: Subject: Re: [PATCH v2] Bluetooth: Fix update of connection state in `hci_encrypt_cfm` To: Patrick Steinhardt Cc: "linux-bluetooth@vger.kernel.org" , Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Content-Type: text/plain; charset="UTF-8" Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Patrick, On Wed, Jul 15, 2020 at 10:45 AM Patrick Steinhardt wrote: > > 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_encrypt_cfm") > Signed-off-by: Patrick Steinhardt Acked-by: Luiz Augusto von Dentz > --- > 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_core.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 *conn, __u8 status) > __u8 encrypt; > > if (conn->state == BT_CONFIG) { > - if (status) > + if (!status) > conn->state = BT_CONNECTED; > > hci_connect_cfm(conn, status); > -- > 2.27.0 > -- Luiz Augusto von Dentz