Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1671131rwl; Fri, 24 Mar 2023 13:53:50 -0700 (PDT) X-Google-Smtp-Source: AKy350bZjDP/7buEBGCQgrvENr6bJPdHxa/o1CApvyG3CS0KfpzApDnhl6R9x2oH+fp0qE9Cxcbn X-Received: by 2002:a17:907:2095:b0:8e6:266c:d195 with SMTP id pv21-20020a170907209500b008e6266cd195mr4101543ejb.38.1679691230037; Fri, 24 Mar 2023 13:53:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679691230; cv=none; d=google.com; s=arc-20160816; b=yR66AZh1p1v4HXo5uHhlrUKSpr9M4HErDc54aKz0S3aeYzrHnBdynY/s1bjL0SL2Zt aJmBt9M67l6ceWaaior3tahLJp6Fnl1QP6Pv8qzl4cC/SDNDLuuxPijk6AfPXtkb3SoF 7U8pgEaoAfQF5YjULtSypCXuVAHwDo/h6hlnLmavBpG6NrHPDkhGCDEdkEEFvIa56V+v OJUsI7Z3Fa85KCfMtDSXAsM5vuvGQ3ln2CCnwNzUfgs37OrfoO9PiX0mxENvEeF9eBx9 qiAJnNnAVtmcnIWZtb8IhU/IJxwfDDnNdApqDQMG24hQ48IMOpBd8f5JMh4Vbda85AdM p00g== 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=+YS09zI3BeC6qLdy+j8+XLDLQAeP9klu5vA1JknSdI0=; b=0ND0xzNw3uiaEHMZbLaEqviaR+0ok4q8mZ3n1gDRGNKgnNl+BpFLjZ0vcJE9jKPXxm xxotmGg7kX9n481P93zbvXhvhj5BaiIckksrIvXxElR7mEsyYAkcLq8JxiPJ9q1xwPdM MRxq1b1xeaWDZFrEArfpBJ22okgQYCsQnhPvq+E80n5uHuKl0tR5faGB7OcQV8khIsRf OjQ2JjCB02qNPQM/8UyUB+5mt9jmON/ZQv2F3HW/c/VSfHWrq4jcjQ2oXafyn7lmGwVB rq1losgm6dofj8ju6+KcU4ZzIUomwBWKg3e3IxH3LbYoCM/21HfTqg7EsovJUloFlx+v ytdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="V/KQRtc5"; 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 t18-20020a170906269200b008cd525eac74si17608220ejc.836.2023.03.24.13.52.57; Fri, 24 Mar 2023 13:53:50 -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="V/KQRtc5"; 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 S232225AbjCXUpa (ORCPT + 99 others); Fri, 24 Mar 2023 16:45:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232196AbjCXUp3 (ORCPT ); Fri, 24 Mar 2023 16:45:29 -0400 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D992213DC1 for ; Fri, 24 Mar 2023 13:45:28 -0700 (PDT) Received: by mail-pg1-x52f.google.com with SMTP id s19so1852684pgi.0 for ; Fri, 24 Mar 2023 13:45:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679690728; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=+YS09zI3BeC6qLdy+j8+XLDLQAeP9klu5vA1JknSdI0=; b=V/KQRtc5bw/aFMCiTKCRoCl6vzJ8a1TNiYLEsQ9giM6sKD4qcRSqQb3hFYvmhM1exV 5bbZdWinXYlmt0Xj+PRVJitM8heZ3D6t9a/dNbN4geDD8Hj9OdhxX+MQoqhF/sjQ87Pr 6UQ/FZn41AdGTS6buP76jYgpq6DL2WzdCSKW7nqXFJeaiVsVKJLJfvi6NFFzGzoG6rlc IeWMMKWirTwnAG64pBzC0S8yNx2PlN8EN11txTfjo294Fo3ThoACUktEYa87kAZcd261 GrSs8tXr0hQqd+czPb4anNLsZmvND+2TYXAgIMNcBMWYejzm89Vccnuj0IPGbRu7XnVz D70w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679690728; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+YS09zI3BeC6qLdy+j8+XLDLQAeP9klu5vA1JknSdI0=; b=4MrEj9xy47MofRTiJ19qG69Cqlm4AgDtZj7CGXPxJtgZxXqbmCG8M00JzVQSDiggz5 HXiWXiwRjBpteROviS4Y2Fc4nBu81YI+SWOCntmVyPlrXjLpuPJFvdKlnAKYev4Bi9oc PHbMCTV6moDKJoIZ7JwUf07kFfYATdaK1TsNAX1IGBuKCFUjTJOwim+S5bgq1pAQV1AV QxyBu5rLUUN2a49+EaQF8oQYa8tJJXlr2BFExVO+Sgjs72xiaKAYxfZ5gqehIgDL8elv X04jcGUmhcVx3pIx2h9AcFO4FPqRmbme6+QAYRhrOkVceo4FnnfGkik+3PvOdJEvL8xh FlnA== X-Gm-Message-State: AAQBX9dqYxA3+T3P9yR6Ddj643M1grdjOJzSH5SxFrR1A2TcAJ4yqHiM VavuwX+9gZgCb0ooVC3yMFuoZAiCeFc= X-Received: by 2002:a62:6401:0:b0:625:c9bd:57de with SMTP id y1-20020a626401000000b00625c9bd57demr4164918pfb.30.1679690727551; Fri, 24 Mar 2023 13:45:27 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-59-129-171.hsd1.or.comcast.net. [71.59.129.171]) by smtp.gmail.com with ESMTPSA id y13-20020aa7804d000000b0062b485b8e5esm1669916pfm.81.2023.03.24.13.45.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Mar 2023 13:45:26 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH 1/2] Bluetooth: hci_conn: Fix not cleaning up on LE Connection failure Date: Fri, 24 Mar 2023 13:45:24 -0700 Message-Id: <20230324204525.3630188-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 hci_connect_le_scan_cleanup shall always be invoked to cleanup the states and re-enable passive scanning if necessary, otherwise it may cause the pending action to stay active causing multiple attempts to connect. Fixes: 9b3628d79b46 ("Bluetooth: hci_sync: Cleanup hci_conn if it cannot be aborted") Signed-off-by: Luiz Augusto von Dentz --- net/bluetooth/hci_conn.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 17b946f9ba31..0cd339ba7858 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -88,7 +88,16 @@ static void hci_connect_le_scan_cleanup(struct hci_conn *conn) params = hci_pend_le_action_lookup(&hdev->pend_le_conns, bdaddr, bdaddr_type); - if (!params || !params->explicit_connect) + if (!params) + return; + + if (params->conn) { + hci_conn_drop(params->conn); + hci_conn_put(params->conn); + params->conn = NULL; + } + + if (!params->explicit_connect) return; /* The connection attempt was doing scan for new RPA, and is @@ -1181,13 +1190,7 @@ static void hci_le_conn_failed(struct hci_conn *conn, u8 status) struct hci_dev *hdev = conn->hdev; struct hci_conn_params *params; - params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, - conn->dst_type); - if (params && params->conn) { - hci_conn_drop(params->conn); - hci_conn_put(params->conn); - params->conn = NULL; - } + hci_connect_le_scan_cleanup(conn); /* If the status indicates successful cancellation of * the attempt (i.e. Unknown Connection Id) there's no point of @@ -1200,11 +1203,6 @@ static void hci_le_conn_failed(struct hci_conn *conn, u8 status) mgmt_connect_failed(hdev, &conn->dst, conn->type, conn->dst_type, status); - /* Since we may have temporarily stopped the background scanning in - * favor of connection establishment, we should restart it. - */ - hci_update_passive_scan(hdev); - /* Enable advertising in case this was a failed connection * attempt as a peripheral. */ -- 2.39.2