Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6698147rdb; Tue, 2 Jan 2024 10:08:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IEISqeGq5GtXI+bYdzcdxVO8o/Dz8GkkZGyQB7TIqBE0Cq6vCR/PGyopxr3pEzZW66LHorF X-Received: by 2002:a17:906:748c:b0:a28:814e:4f02 with SMTP id e12-20020a170906748c00b00a28814e4f02mr29381ejl.131.1704218918664; Tue, 02 Jan 2024 10:08:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704218918; cv=none; d=google.com; s=arc-20160816; b=GgYIIKcaQRwXiCDetiFKDVUiVLdVuJJGuU9z3PSPvvJ7+5I8GZ0Nb47/b1Ve2wXhvg U3FOLEIIWSa+9EpXLP96s53TIBirb0PgxSn+qC6jWu82ZkiFZ+/H5VFYl3N8eEtQpx/k yxE2+q++61WlnUvQbteYca74BBj56KAhuMC2Kt55JVV/fOaT/ybR1OCl6fOjYJnz4JDb yvnUZoF4lSFVzWC5RaLTdIHSptbqp9mltgPsYdCjWXTqIc1dMnN1KXca5ArlGBjrREH6 Pmxg7v7HWbFgODkIMKxd2MfrsfBwVOS+FPnj96dr2m8LrOMy2CDpe/+4ZSNCZ/CkRReD PHng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=w6Mc8Fn+b4ZhDRXIGhnPopUw1oq5lVm3emVM0Lhv4e4=; fh=3AqDzvZy8BuFcn015+g5AB3sGQnZc/edyFwniXfpO+U=; b=p3oIUkvyfQMyL8HtSJQujB74iOW0gR1i4d915Ctn+qe8iSHGfRfEnGQ7OXhU0NWhgk W5Fnt4Wourzyyqt047LxA+fA8E/o72sxqWvZePplaA5u0L2IY/GeKb5UJ75y168eKnEb NMYxT2VTHDhL5PQxSKT7l+vnXHatn5ofJC8+8cpWhTgI2JOHO2TY1Nxc4Lt8wOhurl5+ BFIdyDjn32InoqTAV7u5lQRuwNJa2wH28Qq5miCoWNGPJ6HcXaWQYPilk4JcJOWapbsK 2sh7DiYzM0SkHsDTghiCV4gYKkloxtBT8XKzkbHcL5AE9T8ux0AvNN0Bf6tNpDBT7z4C aLrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth+bounces-816-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-816-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id e17-20020a1709062d5100b00a26a25cbdb5si10496213eji.451.2024.01.02.10.08.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 10:08:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-bluetooth+bounces-816-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth+bounces-816-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-bluetooth+bounces-816-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6C6011F230D0 for ; Tue, 2 Jan 2024 18:08:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D81C1156E2; Tue, 2 Jan 2024 18:08:27 +0000 (UTC) X-Original-To: linux-bluetooth@vger.kernel.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88E43156C3; Tue, 2 Jan 2024 18:08:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=v0yd.nl Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=v0yd.nl Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4T4LSM3qWKz9srQ; Tue, 2 Jan 2024 19:08:19 +0100 (CET) From: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: =?UTF-8?q?Jonas=20Dre=C3=9Fler?= , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH] Bluetooth: hci_sync: Check the correct flag before starting a scan Date: Tue, 2 Jan 2024 19:08:08 +0100 Message-ID: <20240102180810.54515-1-verdre@v0yd.nl> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4T4LSM3qWKz9srQ There's a very confusing mistake in the code starting a HCI inquiry: We're calling hci_dev_test_flag() to test for HCI_INQUIRY, but hci_dev_test_flag() checks hdev->dev_flags instead of hdev->flags. HCI_INQUIRY is a bit that's set on hdev->flags, not on hdev->dev_flags though. HCI_INQUIRY equals the integer 7, and in hdev->dev_flags, 7 means HCI_BONDABLE, so we were actually checking for HCI_BONDABLE here. The mistake is only present in the synchronous code for starting an inquiry, not in the async one. Also devices are typically bondable while doing an inquiry, so that might be the reason why nobody noticed it so far. Signed-off-by: Jonas Dreßler --- net/bluetooth/hci_sync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index c920de0a2..4a5949a0e 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -5554,7 +5554,7 @@ static int hci_inquiry_sync(struct hci_dev *hdev, u8 length) bt_dev_dbg(hdev, ""); - if (hci_dev_test_flag(hdev, HCI_INQUIRY)) + if (test_bit(HCI_INQUIRY, &hdev->flags)) return 0; hci_dev_lock(hdev); -- 2.43.0