Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp3276448ioo; Tue, 24 May 2022 18:33:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCdr7muxbWtAXBzmNGS+RCWKdH7dQm5IY/A1Cr5P9FrlJHezc0QaAItT+HlD+2WW2/xlIu X-Received: by 2002:a63:4e20:0:b0:3f6:52e5:e4cc with SMTP id c32-20020a634e20000000b003f652e5e4ccmr23516029pgb.421.1653442395215; Tue, 24 May 2022 18:33:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653442395; cv=none; d=google.com; s=arc-20160816; b=z4ulXHNjI53r6E0sCviBpEEvuElUAmFCyQKR6NyeOFIX8aiWD9LQ2xJeN514p6b6Km KOYYGwUganCW31J3YceukQN+aVlSFlZLNQ2inmauoV+NeQbElKZlX0ejWvZH2te8mIt/ iWTtgMWTfainTblPig17ZiTQ9Ef3yAg6hFYvqdxJCgqIQwsMsO3H15gXHhW8auJb5pm+ glVWIpcVnOxsl2fBxd79tfErMk+qdm6INUcFP29lwIDNDZgYyME9gLylSWQkVAU37Usd bm8S0BW4ez5GwlqRC8+8XoDzp7O85GxPD684T518vilH2I+6yCv7p3n5SSMnWOfjY5HI JDMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:cc:from :references:to:content-language:subject:user-agent:mime-version:date :message-id; bh=OYpn6bOoK+OAzDOCy2uB8+i1ukQS/itx/eqnSrc4dy4=; b=P64UhBziKjpzauniod9WyG3E3zow9fgNowvGNtL14sZuM/gpqZQNRS73YwJ0MAruJ9 b1vC6Qhr3LAa9gc2e21ze9szwgd1Urhu6n96+e3AmeYOotdddDJaK62+xD0WjLwFrCzU m1PEVJthklaJCA1goBHrZoFk1TSjKmFFov5XNNMWiOKmtySp7EPzIGwTUMIdarBYAkgR pLoRMfhm8DDyRnlY4ME9A7Xxlb101OSDckxipemsp2dZ8uyxkowWoBALz9hnlf+oN+/m 6g0klqU2MSZ0p5zIBw+scNa9ROGq9laxQELBxiC9dCseN41CmcCJKwm/L4HZetIyQ8rE CKDQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p10-20020a65490a000000b003fa8a914590si7110293pgs.56.2022.05.24.18.32.49; Tue, 24 May 2022 18:33:15 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233600AbiEXOsU (ORCPT + 99 others); Tue, 24 May 2022 10:48:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229967AbiEXOsU (ORCPT ); Tue, 24 May 2022 10:48:20 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51EA79B185 for ; Tue, 24 May 2022 07:48:19 -0700 (PDT) Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=[127.0.0.1]) by metis.ext.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1ntVpY-00016O-Kq; Tue, 24 May 2022 16:48:16 +0200 Message-ID: <148a9f76-0784-1d17-22cd-80343895aa37@pengutronix.de> Date: Tue, 24 May 2022 16:48:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH-stable] Bluetooth: hci_conn: Fix hci_connect_le_sync Content-Language: en-US To: Luiz Augusto von Dentz , linux-bluetooth@vger.kernel.org References: <20220520183713.2641513-1-luiz.dentz@gmail.com> From: Ahmad Fatoum Cc: Pengutronix Kernel Team In-Reply-To: <20220520183713.2641513-1-luiz.dentz@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:900:1d::77 X-SA-Exim-Mail-From: a.fatoum@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-bluetooth@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,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 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. 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 |