Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2377851iob; Fri, 20 May 2022 08:05:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEUr5ip1qi5ZIg/V+L6JldIBLyH3Zw5c5j4BL20+VCZjfZRhG1/wglFSqGXRSGKGdp/r/M X-Received: by 2002:a17:907:6e0c:b0:6fe:89d4:e18a with SMTP id sd12-20020a1709076e0c00b006fe89d4e18amr9078969ejc.65.1653059157308; Fri, 20 May 2022 08:05:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653059157; cv=none; d=google.com; s=arc-20160816; b=b4IpVtF/U1p2erjft2bobRQVtrqFyaiMix0BbWql3r3Dnjl8P7N4XhvicT+VbdXDSZ eLsfFpwjQq3uNlBGNk9wL1NHHEWHLTe00NAQNiuLgOaKnqogcMzcFB7DITRJ9lj1wNMw NzngZplXXdqzadZhKKoCWOYR/NdGlhA0nSG35PNcOL5ez5rSw33m06MSN54rX4/cnoUk j0C0A3OqgYymJZtwDP8wlz8R6UCR0RE/REokY6ktKsR2h5URMhc0W3mypJdlgEbxxmQZ nabsPewMxPu9jgJCcBhnSMwQ7Cpks3xiexMRmrG62ecUTSyWpbOy1Jhf9uEwSRau6WWb ayIQ== 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 :message-id:date:subject:to:from:dkim-signature; bh=J5KE7dwc120qeok1CZgQ5szINl5mYleYsk/m0GI/AVY=; b=pd8HriVdauRFhlnLlh6elKM1fK9gHwa0q1e8b1fxtuwYuySyxaw7qvteqauzqPOILz xRmsnZK2GLfBVxS89fVihMRe31IS20ILQ0FyZsBZK1WHMaZQN6nFAOoG6CqPfx53ek4W Yv/ExmT2vTLi3Ow4MaZhqwbnPPPrPMzUNZFx/6QxuLrd2ydKY0lIGWE+0jgNeoBU6ccU 8B6gd0nTY+hwDaXedQ90VGprIYbpbGS/fBfXico89lblTB1HYLrIgFeuke4eP3sKHtDB cG5oIXDG9CyKS3tW1OSS1OiENv3WnEjuBxn0lsRC6lKxLG/UpWMblIPxP8HboEbvo+y1 wdqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=SqOqcjCk; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nd25-20020a170907629900b006f3be13d016si9119045ejc.37.2022.05.20.08.05.15; Fri, 20 May 2022 08:05:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-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=@gmail.com header.s=20210112 header.b=SqOqcjCk; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S244681AbiESUXB (ORCPT + 99 others); Thu, 19 May 2022 16:23:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244553AbiESUXA (ORCPT ); Thu, 19 May 2022 16:23:00 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0871E9419B for ; Thu, 19 May 2022 13:23:00 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id l7-20020a17090aaa8700b001dd1a5b9965so6203895pjq.2 for ; Thu, 19 May 2022 13:23:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=J5KE7dwc120qeok1CZgQ5szINl5mYleYsk/m0GI/AVY=; b=SqOqcjCkbdqtsRjpAbUZjmpsaRD81ksU2rLh+A31lOwjWwjFSumDNMVrVa5O9rzjo3 pZ/+4KwX/o95zVyWWctrc0+ppCTOffjoXP39jBW60BFv8pmezWMmElVMyeCkKEN0K/XZ ps+OOW9whxRNFObK9OovrAfm1waogTBZJPbnEEE4k3R7ofa9ZGI/5VedFaqkZTroRnJf B6j7f8L6IClN7AR4d7yN4iSv+AwgsVDPFAnZ5PuyCcDA6NIqkiVsLV5jpQ119gK9rK/0 R5XA9z6D7f0wsDzI9BicSMYncJ3Qi5+ILoonWnAoYAm+m3f0T4CbaZYbh/0SSMSquLb9 h3Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=J5KE7dwc120qeok1CZgQ5szINl5mYleYsk/m0GI/AVY=; b=iAZ08DWJWSm+BBBs05H4xvVJga8vr/yFfZlVR27D/4E+RwjL73pFEGQcGguz+zZOw0 UUjFUq4W8Xwa4VOVKyaZw71rGhxq425Xgde0dN/M65uXCWnlpY69pJ+CJkiCzVZjA6I6 QTuIvupuxED2Cxz7H6fEVfWqsn/HkUfQq7JMscGDrwuRxTlOEBj5pdoX4Ci+nFGXAVdw 2AnyIPk11k8ukH1JrCSrGpdfV8KTV2hu/4EuxQg9US1dUstjGJdzjWOX9UQ1qADmTzk+ +8FfrDP7O2FNoUPZnB9gnlTKNuFKDUpKB/y05wVPPUWxaY6LvtTL6hkJwzhpCi5zIKSP ISPA== X-Gm-Message-State: AOAM531fr9eOKERIWOsPXKt/hIdLyEZFN6JUhCFpBpM/cWXS3UhVdXPk h/qTYnRX93cjZ2qrbgNo5H1adDqM1qo= X-Received: by 2002:a17:90b:164a:b0:1dc:981d:f197 with SMTP id il10-20020a17090b164a00b001dc981df197mr7498591pjb.228.1652991779209; Thu, 19 May 2022 13:22:59 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id i6-20020a62c106000000b0050dc762816csm98003pfg.70.2022.05.19.13.22.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 May 2022 13:22:58 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 1/3] Bluetooth: hci_conn: Fix hci_connect_le_sync Date: Thu, 19 May 2022 13:22:56 -0700 Message-Id: <20220519202258.2459530-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz The handling of connection failures shall be handled by the request completion callback as already done by hci_cs_le_create_conn, also make sure to use hci_conn_failed instead of hci_le_conn_failed as the later don't actually call hci_conn_del to cleanup. Fixes: 8e8b92ee60de5 ("Bluetooth: hci_sync: Add hci_le_create_conn_sync") Signed-off-by: Luiz Augusto von Dentz --- net/bluetooth/hci_conn.c | 5 +++-- net/bluetooth/hci_event.c | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 882a7df13005..ac06c9724c7f 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -943,10 +943,11 @@ static void create_le_conn_complete(struct hci_dev *hdev, void *data, int err) bt_dev_err(hdev, "request failed to create LE connection: err %d", err); - if (!conn) + /* Check if connection is still pending */ + if (conn != hci_lookup_le_connect(hdev)) goto done; - hci_le_conn_failed(conn, err); + hci_conn_failed(conn, err); done: hci_dev_unlock(hdev); diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 0270e597c285..af17dfb20e01 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5632,10 +5632,12 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status, status = HCI_ERROR_INVALID_PARAMETERS; } - if (status) { - hci_conn_failed(conn, status); + /* All connection failure handling is taken care of by the + * hci_conn_failed function which is triggered by the HCI + * request completion callbacks used for connecting. + */ + if (status) goto unlock; - } if (conn->dst_type == ADDR_LE_DEV_PUBLIC) addr_type = BDADDR_LE_PUBLIC; -- 2.35.1