Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3106776rwa; Mon, 22 Aug 2022 21:45:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR52JZsRd0MYYPFDHkAPbAoGHuMFVK4pS72IIFg4TN+CsMICYzqn9KDFoQa6+UQYQrRDcz51 X-Received: by 2002:a17:907:6d8f:b0:73d:8416:908b with SMTP id sb15-20020a1709076d8f00b0073d8416908bmr4510351ejc.651.1661229926723; Mon, 22 Aug 2022 21:45:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661229926; cv=none; d=google.com; s=arc-20160816; b=MWUaWb3yNQzKbpiLSrn7qJrpU535ACtHwvUaLumzWNBFhZBqQS4edi4nYrQMNchyYI 4HyTq73c1rV4SXnZFSgvl8HktCdfyRsXBwnquMwxHJS3V52H+fZRccAfQqYdWqrZV56/ y0AWN6Df/wxHcauR0qoNEfLR403XRw57D06GgviBFXFjYNEd+WCc8Z5rAUAkZbvISM5j skBRgBd2F5duzutQxfv1Bh3vZ+QK2PVYN2kZB8fKUZudCcnPN8uqAYlTlM761xUy7BUK 9KsO4dD1pKglEzDUjxvE8ilH1o5omvRxnKlKw0DiYp54e2V2jNEmlZfYNyw9oJOTkEHK jMhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=eCx7HCyYhMVr1Cnt8cn0N8ALL0nL9w7hY17tTHbimY4=; b=QFGyN1b/yQe3pnfj0wQxYyMaJq+YJ+k0+IecoMSvZGDA1KaYe9ZgsUTqwwx8e7/JYH JC+8/evpLtBMCRFcQR8qIcx9sXv1/G4ZlxYsSrmO5kSo2p8V0lpox3GSqxOrZEDUkIEr CPTQgevBnyZ35W0V1BP/iVKF4/74NsKKtL2tMTqvA0k7JdJSDOO33mangQ86Sw1z9ktT AJwJXLKXRzsot3I7ufsqzN5RGGhhYhnGYA5B4hQp9maaaXH9mGaMDkYKLYjxOUBfVfyU 3d/n/T3NQJ/Aa3o85jk3Io/JffbY5xaNyt9W3Hz3SxLwkchJMij4b6DJSpzltuRdHIaq AjFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=jrnCAzZ8; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f10-20020a50d54a000000b004409963eb80si1184502edj.432.2022.08.22.21.44.54; Mon, 22 Aug 2022 21:45:26 -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=@google.com header.s=20210112 header.b=jrnCAzZ8; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239523AbiHWEjb (ORCPT + 99 others); Tue, 23 Aug 2022 00:39:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236382AbiHWEja (ORCPT ); Tue, 23 Aug 2022 00:39:30 -0400 Received: from mail-yw1-x1149.google.com (mail-yw1-x1149.google.com [IPv6:2607:f8b0:4864:20::1149]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DFA952813 for ; Mon, 22 Aug 2022 21:39:29 -0700 (PDT) Received: by mail-yw1-x1149.google.com with SMTP id 00721157ae682-3345ad926f2so222030717b3.12 for ; Mon, 22 Aug 2022 21:39:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:mime-version:message-id:date:from:to:cc; bh=eCx7HCyYhMVr1Cnt8cn0N8ALL0nL9w7hY17tTHbimY4=; b=jrnCAzZ8mUui4idMn39tH4y6Hp+N0XhYghte0f+EXUBENFnuTJtssjk83zBHZO8tBM juElvdV++c0aVazJQdJqkTHu6n4jPwo9ZSr+XUmZr44YblGyK2Jj+AxOBl/eiCSMEfxf fYR1ewqUaNjWXP4izPlufq9DPAx8V7QVm1MBDH9sthYlvugzZ/gPdoE3d7F9YwS0MDFl Mp0tdXCt2GjFwrtLBOWvWtaJiY9CtQ0QjtBmwwMSpYWZmusRitLQQgoWqYJX5GmDUabQ UUlxV2ZWWUWLBTntSeYTxvRrODg8VhgTipUx/ujbaXrKXQVgcCp7jjEPkEnhD/w6rWTz 6EDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:mime-version:message-id:date:x-gm-message-state :from:to:cc; bh=eCx7HCyYhMVr1Cnt8cn0N8ALL0nL9w7hY17tTHbimY4=; b=Vo2QX2t9KIzbvDe4p6S85j1zW2d2B5x9z1U1g8sqFfDKI/qkiI7RO9gWKh6tWNP17i TBtyTWzwP/P9fU/eRiBW2vO0sOCqo4MOZwgFZggsXHKAATyK26L8lFkhKomNIkc2Y1my TK0x5YYfah+GiWW1nr4YciyGyf2UmupsXWh8E6Jh3Q++lL1XZ7Wcdxd2RoQItNeb8pcO RfymGrxOllgCEPh3at2sdiltpGVbD/swwyfi1VO716WK5O6iwa+Iv95nvTAd9vogFMbh rXBGops/CW2YE786LsVp7wSbnZiwOB8U1T2ghuchnm9kLwfdq42SvGSxeF37Pt4HcYRh G16w== X-Gm-Message-State: ACgBeo3b1vBVX8hbdqEomKQoRVa3r2BVJSKtL5RDfXVACO9MxF02Vjbo n5awTyysw4s0pXr0ofgAHPQd9Za1+kKt+9whkJeXEwzwFReODyyrD85TbU8ZZ7NUCwbpJXicYdc 4vdL7TzZX9yQLA87ZtkLpQFb8QNCG7PNu9G4GTF2kKT2avbnPYSM49h2242lYqN6DgAdPvJn9aa GS X-Received: from apusaka-p920.tpe.corp.google.com ([2401:fa00:1:17:aa4:997c:9497:366e]) (user=apusaka job=sendgmr) by 2002:a25:b986:0:b0:671:a73:1ea6 with SMTP id r6-20020a25b986000000b006710a731ea6mr21903490ybg.405.1661229568686; Mon, 22 Aug 2022 21:39:28 -0700 (PDT) Date: Tue, 23 Aug 2022 12:39:22 +0800 Message-Id: <20220823123850.1.I0cb00facc6a47efc8cee54d5d4a02fadb388e5a5@changeid> Mime-Version: 1.0 X-Mailer: git-send-email 2.37.1.595.g718a3a8f04-goog Subject: [PATCH] Bluetooth: hci_event: Fix checking conn for le_conn_complete_evt From: Archie Pusaka To: linux-bluetooth , Luiz Augusto von Dentz , Marcel Holtmann Cc: CrosBT Upstreaming , Archie Pusaka , Sonny Sasaka , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Johan Hedberg , Paolo Abeni , Soenke Huster , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL 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: Archie Pusaka To prevent multiple conn complete events, we shouldn't look up the conn with hci_lookup_le_connect, since it requires the state to be BT_CONNECT. By the time the duplicate event is processed, the state might have changed, so we end up processing the new event anyway. Change the lookup function to hci_conn_hash_lookup_ba. Fixes: d5ebaa7c5f6f6 ("Bluetooth: hci_event: Ignore multiple conn complete events") Signed-off-by: Archie Pusaka Reviewed-by: Sonny Sasaka --- net/bluetooth/hci_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 938abe6352bf..1906822a061b 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c @@ -5801,7 +5801,7 @@ static void le_conn_complete_evt(struct hci_dev *hdev, u8 status, */ hci_dev_clear_flag(hdev, HCI_LE_ADV); - conn = hci_lookup_le_connect(hdev); + conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, bdaddr); if (!conn) { /* In case of error status and there is no connection pending * just unlock as there is nothing to cleanup. -- 2.37.1.595.g718a3a8f04-goog