Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3548368ioo; Wed, 25 May 2022 03:11:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFMcZY487WDmO04ZuNwIpB0rsHOK3yQRbbyXIy+0PYWjcoG0jigxoqP+GEk7Wz+sA+2jwn X-Received: by 2002:a50:fc06:0:b0:42b:c6d3:6ff0 with SMTP id i6-20020a50fc06000000b0042bc6d36ff0mr2800521edr.213.1653473505979; Wed, 25 May 2022 03:11:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653473505; cv=none; d=google.com; s=arc-20160816; b=zMgAODnygrZgr0fB1QTfxQ3Z+8uJw2p2oCshhhAxwHJvf/R+6cn7D8osem9g+CQT7C LXLx9iwRBd1DFdBGAb9PfaZqkinMKEuK9xigG55MNP6cTn0FryeSKuSwAcjtzwCdVYxt RTwkm3EIrpg+RyUC3fp+INnkTOsuolLYDzyLkeghlsM/I7JZzVAoJiztAzH8xk0pNglu u4EFOkSkreFwEEBVfVEZ+ru3q428cqec2kzVPEzksb6FDVLPH2dG9JUgJ5/cPQ6OdTLA FapcQLa5sWaJNmewpmLnC+pn+T0K496hMjcElnYmcRM4bSxqAYFtUSktwO1V54IvQ3fD mDmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=P6jEhRYBuWpsNnDD04lz5yBNR701Qvg5CrX6H/2zQns=; b=kEo9rL0pHBfCrXWActPqb+GlNQTVw7/HiH3zCrj3pG67ZnXVujiXtw6Mb468RFTnQv IG0TG8SZX2avxRxb9bJ8XVDyvG7YYqzi/mRP4atE9JXyYBmyaIcxCmhu7hDtBWgBbVF3 fXXavdKTncB809TY7KmIMFPSDZv3vccdAkvnDg303/D4kfgSmeTnd7ClP2O4lWR910+9 9+bcTHXQfj5Ql20UbQvcchdImy32jSJknteeHc/aMB8N4J3Kl/VUu8+vnO4OQjmllJlB 2Mz3u16yeOWIGuYjwu58DI2BYVuMzt1mx1J9ny5g+iNLkf5ZwIviCP9ZvKxkTX7Lyrna eobw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=E6CH5dAW; 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 z9-20020a056402274900b00423d5e26a5asi5568738edd.576.2022.05.25.03.11.06; Wed, 25 May 2022 03:11:45 -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=E6CH5dAW; 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 S231981AbiEXSIj (ORCPT + 99 others); Tue, 24 May 2022 14:08:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240182AbiEXSIj (ORCPT ); Tue, 24 May 2022 14:08:39 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B33D46B08B for ; Tue, 24 May 2022 11:08:37 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id p13-20020a17090a284d00b001e0817e77f6so1892246pjf.5 for ; Tue, 24 May 2022 11:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=P6jEhRYBuWpsNnDD04lz5yBNR701Qvg5CrX6H/2zQns=; b=E6CH5dAWA610CekiEz9VwVayPGHwiOrWyYSiKWab0JyGaW+3y/U18sdjy31+DPCG1l IJ6fliYPRpsnbu4V0tf2pE3OEP+voFuRTyty4cvIiWRAD/GP5QaNxpQ2quvECvUgshiD Iv66jG4OsLD0vlUfLmcOjinH1T8varBVUHO0sAmTFFjDeQVYM2E3PK04Wf5WflbFQQDS eK0VLzO+gpZdPA8U7BCz3af/0kD9J9zGPzSnUzkeiEx0sJR3ewGjuamzKvLhAdFt7Ef1 I64OQDtic/L4KiuIEhYeDA+MKOhuxxE0rAo0wC0Iw6pfSG/GeGU0Ie0ynytAX73YkHkt brgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=P6jEhRYBuWpsNnDD04lz5yBNR701Qvg5CrX6H/2zQns=; b=uMsvDjs8q2uX1S+c3aQsiVc2ekgCDQjLZvZnMCVMlAY8vtmzaFGLABfaOdNRzkm6nN DqeBIgpSSJRq5KB6P6jQsFgmCWdI8jGVoKUzcR+rwiuZ8NT2wsmnGM2HiwSvoKF7E1EN GvHXqF0nqmZFBkMdJDVCPbr3gL7gvC8/sPy+/3a0x7JG41egcZ9AaXOE4LZnOeIHDnjm svBOlo+nSjmkZldgZyRE5U7b5eP7PS9t9uufDxrBk8zjUxJaMG0kbK9KQT4taM27KAyn l036M2aBjcWuqyfMT9J1y8K6y7wNq4Pb1IRQTHxZnpjBc0c3JWqfD0SCI5+lY2JQ6Fpq HHBA== X-Gm-Message-State: AOAM530/MLMSnZicoN4/vjcLtoH10YOstQA7P4eZW7eW4W0I4wdXLm6W OOg+igigYGD7U7dO0Qr4RdGi029136cw71DPYpK7EIu3eO4= X-Received: by 2002:a17:90a:3cce:b0:1df:8f80:ef7a with SMTP id k14-20020a17090a3cce00b001df8f80ef7amr5905607pjd.4.1653415717034; Tue, 24 May 2022 11:08:37 -0700 (PDT) MIME-Version: 1.0 References: <20220520183713.2641513-1-luiz.dentz@gmail.com> <148a9f76-0784-1d17-22cd-80343895aa37@pengutronix.de> <9e5b51ae-5089-dc91-57cb-52b0d76249d8@pengutronix.de> In-Reply-To: <9e5b51ae-5089-dc91-57cb-52b0d76249d8@pengutronix.de> From: Luiz Augusto von Dentz Date: Tue, 24 May 2022 11:08:25 -0700 Message-ID: Subject: Re: [PATCH-stable] Bluetooth: hci_conn: Fix hci_connect_le_sync To: Ahmad Fatoum Cc: "linux-bluetooth@vger.kernel.org" , Pengutronix Kernel Team Content-Type: text/plain; charset="UTF-8" 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 Hi Ahmad, On Tue, May 24, 2022 at 8:55 AM Ahmad Fatoum wrote: > > Hello Luiz, > > On 24.05.22 16:48, Ahmad Fatoum wrote: > > On 20.05.22 20:37, Luiz Augusto von Dentz wrote: > >> 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 > > > > A bit late, as I am not subscribed to linux-bluetooth and didn't notice this > > patch, but FWIW: Tested-by: Ahmad Fatoum > > > > Bluetooth: hci0: Opcode 0x200d failed: -110 > > Bluetooth: hci0: request failed to create LE connection: err -110 > > > > now, whereas before it crashed the kernel. > > I see now that this fix doesn't build for v5.17 because hci_conn_failed > was only introduced in v5.18. Can the hci_conn.c hunk be safely dropped? Are you talking about: if (status) { - hci_le_conn_failed(conn, status); + hci_conn_failed(conn, status); goto unlock; } You just need to replace hci_conn_failed with hci_le_conn_failed or well in the code above the end result is the same since it is not supposed to cleanup in the event handler. > Thanks, > Ahmad > > > > > Cheers, > > Ahmad > > > >> --- > >> 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; > > > > > > > -- > Pengutronix e.K. | | > Steuerwalder Str. 21 | http://www.pengutronix.de/ | > 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | > Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | -- Luiz Augusto von Dentz