From patchwork Tue Jan 2 18:08:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Jonas_Dre=C3=9Fler?= X-Patchwork-Id: 184410 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp4600879dyb; Tue, 2 Jan 2024 10:08:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGumGpi+hjfp1vcaiLBYpM23RuAo1ev5EOP9iwK+j1r64romcKQd8bH/uJem0KXjHV1Shh X-Received: by 2002:a9d:618e:0:b0:6db:ffb0:7a4d with SMTP id g14-20020a9d618e000000b006dbffb07a4dmr8069514otk.45.1704218931218; Tue, 02 Jan 2024 10:08:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704218931; cv=none; d=google.com; s=arc-20160816; b=Cg2VdMqyeK90k5UlnI7O1iFB6WnKDyvcV0W4cKzTAEF1cm1g+I9JOMEQoTUtwheyE+ k/aDpd2Zn5+NhqI0Fi/H90UhlP8Qfnem7JcsjNprZwdqz/T6JVfMKaz83kj+mUtnHFGt WaOnsGJneOYkDPOaBFTkWGdphMovpbkvhWUti4Th+nHDOuENoajER0FMcldcRm6iug7Q BISnNNkogW5GoYj/dlamvgMxTpqfu9sd276J521l7sIdKw//fw9/2xPrZ4XFUzp1sTSS PV4cik+CVjbwZtUZAkEC9P4c26f4vzpxeDqIqmdR5CLug7i8IAVl/uZk1HvqIIR3H1yo W+MQ== 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=q+Nwjy/KNGV/1pFZKsO8ah5+IYy4qCj90fba0YJrKfSLkjgKJdI7RvC8jZTaBnhIpy PMF1g8Az0afu6CE1DbpuouRukkYXxtoI0Rs8RSp2CBMvqVt2It2TMEY/nargY0aiV4lQ 5kgD3+wxpR2WjPEmI81Lt7I+q6MQZSTwzliQVz3N+L6ROtMM0+lPAj0O1dYZvyOqlJ5v O0uHJX/tv3MDKJNvWZenZ9c+p2z0fUGyskEpIzMOayMxelUv/4ZmOzwr/FGAN/Dk9T3R WlD/axSiVF3nJ81kbmGcGOn/y5eFgirerXSlTjtEki4Pq+FtFJBviCYz+ILrYGVntcAj R44g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-14692-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14692-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c21-20020ac85a95000000b004280bc4af8asi8702840qtc.191.2024.01.02.10.08.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 10:08:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14692-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-14692-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14692-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 08B231C22761 for ; Tue, 2 Jan 2024 18:08:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E247156FF; Tue, 2 Jan 2024 18:08:29 +0000 (UTC) X-Original-To: linux-kernel@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_Dre=C3=9Fler?= To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: =?utf-8?q?Jonas_Dre=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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: 4T4LSM3qWKz9srQ X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787003069977459941 X-GMAIL-MSGID: 1787003069977459941 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 Reviewed-by: Simon Horman --- 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);