Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp807494pxp; Wed, 16 Mar 2022 17:46:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyBxfj/vcc0xjuY6wIkbTKE/zu/j7pkazAconAqGEwZDiFnaGVhb+r0UIZtX0DEUTT1DbWs X-Received: by 2002:a17:907:94ca:b0:6da:e637:fa42 with SMTP id dn10-20020a17090794ca00b006dae637fa42mr2097378ejc.347.1647478012915; Wed, 16 Mar 2022 17:46:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647478012; cv=none; d=google.com; s=arc-20160816; b=U28cHj/NTYZgHfT68OHgPDymBCbx1c17at1+0HADaCRG0gQ+s24zp1Lc2M7X7ka0H3 FVFaEQVyKYlEJxlFD/Ks2xFLB7Cj4djfysfzhAbO6f1qNxto6PHJCaRPdNHVqmXgoSML 2pixvaA7L5Oiut1cUq0jPVSMepMRTuGks8fRdAfXPAKhP8VvhqOIUQ5RhcHLiHzsFZVb E96FHIbbb4iutIQtuTahsVujZ+Il/ehdXCZ+pbDqsJRsg+Ojkrcri8UweZCydbjKv6m/ 1SIO83U1i7RPAslGVgITNunQjnvnSHokfV/gukQHHjcoEuVYS9XbsQdANfAgmZbFEraj i4Qw== 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:cc:to:from:dkim-signature; bh=RtjHsmXPT8LE+jJTyR39fP968xbgt2lw05SHk5jQS8s=; b=rGd1PUgsE7YTgdirJIBZfQD2Yb4xehPcb+harinDb0+YQNX/8fN2bbF2Rjs/BcSZXk Rkpuyrbw4qPnlB63NprxxBS0KHEMeh9eRTRCVUGJ42gaPqf/Y8MJtFw/S7zZ67QkaNv4 IZNSczSsc3eFMAXFHwwHZ1RDXmyAuvyL9jLmYLb0yaKyhmJZa3HRdO3YKyzRn39IeLjn 8lE0+t6CDQk72UMXta6QX7oneStxFg4mCi9syWtCklzxNvPxbA0eODr0yVwVpvBBvCyK PbVbcbDBz4VC3igQhPnP3ErFSKjItNeG4ak0fRAH5vDm2aF+tC6VGPVoEq+SchhqXd0f GTng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=eHvHbfSH; 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 e20-20020a50d4d4000000b00418edea448fsi393273edj.224.2022.03.16.17.46.07; Wed, 16 Mar 2022 17:46:52 -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=eHvHbfSH; 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 S1345437AbiCPPg3 (ORCPT + 99 others); Wed, 16 Mar 2022 11:36:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240167AbiCPPg2 (ORCPT ); Wed, 16 Mar 2022 11:36:28 -0400 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C60DA6D1B5 for ; Wed, 16 Mar 2022 08:35:12 -0700 (PDT) Received: by mail-ej1-x633.google.com with SMTP id gb39so5029840ejc.1 for ; Wed, 16 Mar 2022 08:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RtjHsmXPT8LE+jJTyR39fP968xbgt2lw05SHk5jQS8s=; b=eHvHbfSHwH2Y4jvdtNxz9a+SK1FhxfXDwycbRdAMj4LgGfap4mtJxkfWjzE98qQ9c6 jbdPb9pFymVu882c3akJUgSKViEUUZAvrC+8PydMEoFKkl3EGZjW92opDXZMnYXPrY3Q eSL+G/mJHixR7teLNRvBFtbaOMRgiQNdpyjNcepjI5kBKWvrlKNM1zKel8B0muNcrzUB zGa+N3RzSGZDyu8VqgW3P38SR8/at0nQ6zR8j/Rf1QQxa/3gykr7ybee7DEpp0eTRX6y KCrsq+HuERRKO3vBFUPDPzL3FE4xMbp7GJs3/p7+4z9jdK9WeUkyAW/FMlB21jJNmQKl qlqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=RtjHsmXPT8LE+jJTyR39fP968xbgt2lw05SHk5jQS8s=; b=eok8JgA2hr7DefQjAHaaX2+05fw1Q15vSvA6qvvyMz0aX3RDtb2kefe7h3gomgYSy4 qrsrkY+47yUgL8maaK0BkVKpv7GBOWnBMfarP0e8nrpExpwL4xoyUU+iO06jIGwnbVnK x6G432eh6Ti2VO9iCD+CqRSzLdSVrWpsxGWBc+7UpDddGGXAwDPL5c+dFun+ztz9CFSY ytk6tuhuWRjHVXcHDFCF7OJbHNxXL01DSv8Jd2QWhxB7o+N6jsT9sJXIqtX7Z9iFMMtX 2p5Jdq3VzU2mYbTcCloeIC8748riCrl98AfGxGs/8k7KkE2vq6/2D7Ewi+7eBu1q5RXu 8svg== X-Gm-Message-State: AOAM533y0MJFK09Bn6MHlj3GSDJw2a1ompzDtmeXc/L+Vl07UePauhVP ZV47Wk8sl6o2NbHcu2m/EF74VjsNqCZolQ== X-Received: by 2002:a17:907:60c8:b0:6da:83f0:9eaa with SMTP id hv8-20020a17090760c800b006da83f09eaamr406832ejc.605.1647444911145; Wed, 16 Mar 2022 08:35:11 -0700 (PDT) Received: from nlaptop.localdomain (ptr-dtfv0poj8u7zblqwbt6.18120a2.ip6.access.telenet.be. [2a02:1811:cc83:eef0:f2b6:6987:9238:41ca]) by smtp.gmail.com with ESMTPSA id w12-20020a17090649cc00b006d0bee77b9asm1024415ejv.72.2022.03.16.08.35.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Mar 2022 08:35:10 -0700 (PDT) From: Niels Dossche To: linux-bluetooth@vger.kernel.org Cc: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz , Niels Dossche Subject: [PATCH] Bluetooth: call hci_le_conn_failed with hdev lock in hci_le_conn_failed Date: Wed, 16 Mar 2022 16:33:50 +0100 Message-Id: <20220316153350.10047-1-dossche.niels@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 hci_le_conn_failed function's documentation says that the caller must hold hdev->lock. The only callsite that does not hold that lock is hci_le_conn_failed. The other 3 callsites hold the hdev->lock very locally. The solution is to hold the lock during the call to hci_le_conn_failed. Fixes: 3c857757ef6e ("Bluetooth: Add directed advertising support through connect()") Signed-off-by: Niels Dossche --- net/bluetooth/hci_conn.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 04ebe901e86f..3bb2b3b6a1c9 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -669,7 +669,9 @@ static void le_conn_timeout(struct work_struct *work) if (conn->role == HCI_ROLE_SLAVE) { /* Disable LE Advertising */ le_disable_advertising(hdev); + hci_dev_lock(hdev); hci_le_conn_failed(conn, HCI_ERROR_ADVERTISING_TIMEOUT); + hci_dev_unlock(hdev); return; } -- 2.35.1