Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp454867ioo; Sat, 21 May 2022 04:17:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHAE7lFUZPAHKna9A+cmdyqOTPWkIaH4aQJje+WBAgo5J9IJo6R1Qu840ukmmz+RQ1Mhtr X-Received: by 2002:aa7:d414:0:b0:42a:b49e:d502 with SMTP id z20-20020aa7d414000000b0042ab49ed502mr15680569edq.68.1653131822852; Sat, 21 May 2022 04:17:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653131822; cv=none; d=google.com; s=arc-20160816; b=A1fwol7zcl5/7UBL4KCRG8tI2GVWZbSekyAMrzCaafrqxPmpawYU4m/E0bpckhubt2 L2NkihIhrAAhv6nRzPNIxEU278ESvXnUWyi/QI2XcqdNP/Zm2u7u7e/+R5I1d0Wcaham ubEJf1yInl+Ui7NoP8gTPPzUX9MHWG8mziRtmscTwyeCg7zt7aeKSMj/srPOrODh//KB BNt5c4pzTzX8xY7qaictUXGYy/MoAsN5MZ7ib+yRn9/x4qNroWUIZMDdha7rYRujhx44 L9DuUfEVD9a4h/CIusA3xoLkffX5z1k688STpXprRF/2PfJKckNyCVLJ0tljTdS1Pezb zfXw== 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=5uFVZfx3Yq4qswI1QmeoBn2aetKWGS/wSaKxIfc98rc=; b=ydGmSQuhvJrWSKzQByHZa6OElCddBBaG+kfkDVqdYtl6JUOLiPBKYeGYDA/ZRwPDG/ I4C5PYio5Azpjre3Z36jGfdO22EV9T6DDkyg7ZnCEqxVbATPAPLEZv9tLJu1olp4nL+Y XppyVK3S+7+Z/dtXhf4+YLrt92dRIes4GSyaATlvGBVDvPWGc5P07PimuJTqqjxjJGxN kMG+fXRHgG8OPUuaFa8QUWGq/XPhTbrkUoMr58P2h0Aw7x5Xgm3mogrbSnlA+6UY0WYg PFAkcPdhkV1WLZaYjdT1U4qD1I+qQDH4bPRW7Y63bcrAGvZYzrgRCavcgLpy6ICHaEca 7lqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Cmn16T3P; 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 hg4-20020a1709072cc400b006e89c06638bsi10617801ejc.492.2022.05.21.04.16.21; Sat, 21 May 2022 04:17:02 -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=Cmn16T3P; 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 S1352911AbiETShS (ORCPT + 99 others); Fri, 20 May 2022 14:37:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352929AbiETShQ (ORCPT ); Fri, 20 May 2022 14:37:16 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E3106620E for ; Fri, 20 May 2022 11:37:15 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id y199so8423568pfb.9 for ; Fri, 20 May 2022 11:37:15 -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=5uFVZfx3Yq4qswI1QmeoBn2aetKWGS/wSaKxIfc98rc=; b=Cmn16T3PSycAByRlAuFO5xbzl3UBFevSHdW4u9vLE1FYtFrf209QBmvbJ4dMWxVysi yo6jIBpvsvOxqyZwGLtz34wbDfwM783lVWe8lTw1fK1kiZ/HDO/JgIFg077m+fFL0dyJ j5+Y5hybOtjlZ0FUNpPzqnE8lTNW600qvXTNMDufkm7n93CZ6I7LzwIrTsce8/iD/SKV 7ZehbvN7glcAJmgb3XlL2oaEyawVMHSOKeJjz5ftrT/LKeD0nrIUDD/qfUrZljugyYKG F3LbfTdSOAqu7iDe8vWk9KdDp9X2LZA6IWPprqkmTM6h31+UrX2aZPkQMTa4UrO9YC1s kDOQ== 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=5uFVZfx3Yq4qswI1QmeoBn2aetKWGS/wSaKxIfc98rc=; b=gvrqvLYAtexbd/Q0tXWd26gFse4i6lTcdROSXaq75CO1QzUBviYa3r4cNxD2owyQrX l8DhAV8e/ezX2xIje4jGZri9O0aOhxQGRkta6YrB+0iwmKhriCrYaMaDC94HlLqqeoZw Om9OhO68wYIOAUAyp6Q9PM3M4ixItMgN6QTwnIgqiklth80Zywgto7R7WsNHr04VeoI0 GTpC4GUwFgJPDLdWIMBT7xr6KzqOpJUnb5NmnMrbVwKnLcm8qjkU2xF8WPn77loRaerl 7kRBvpjEltRXG2gHrSZFwa+hTszDesjMDjUF4JXUSpxSahmMtw5rcWKHXqzObkz1UkSc SMew== X-Gm-Message-State: AOAM531zvO45uey7msoVJRavZoiE19uWDgLlVKCqymV2g+QFxHurRARD dbBAVei0L8Z6XhpV79RBwuBD7z0IaJo= X-Received: by 2002:a63:e614:0:b0:3f6:3479:6673 with SMTP id g20-20020a63e614000000b003f634796673mr8775381pgh.528.1653071834543; Fri, 20 May 2022 11:37:14 -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 b2-20020aa78702000000b0050dc76281fcsm2097319pfo.214.2022.05.20.11.37.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 May 2022 11:37:13 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH-stable] Bluetooth: hci_conn: Fix hci_connect_le_sync Date: Fri, 20 May 2022 11:37:13 -0700 Message-Id: <20220520183713.2641513-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. Link: https://github.com/bluez/bluez/issues/340 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