From patchwork Wed May 31 08:57:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 687453 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE548C7EE31 for ; Wed, 31 May 2023 08:58:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235251AbjEaI6m (ORCPT ); Wed, 31 May 2023 04:58:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234350AbjEaI6k (ORCPT ); Wed, 31 May 2023 04:58:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FEFDE6; Wed, 31 May 2023 01:58:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B4A5263494; Wed, 31 May 2023 08:58:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B31EC433EF; Wed, 31 May 2023 08:58:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685523518; bh=5iPlGxWeg1puDstJF/Uf9U+q7gbki1LPKTuxWP0fpy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M+G5QG4Ewb9mHrkc46gjlJhtJa/w1G/Pc4kDxiv/43CB5dmGDEyIfvdfWgigSrNbO N/P/n3JP8tmQwfDVaEWuINBWDoVn6G8W1hOZHGAvaWFQvCNzejsg0yZWXeVAvCcEO2 zqwo+lK7l/caqELIRHKPPL8qPaNsXO5yRjAdoMe91CsvqQx7rkqxTFrb4EkU07FvVG DuEUWfYP1QT+mrVYGS6kA3JskT2PD1R8EWe1vyId0kg4paJd54Q/jx9a87XK+E9xHO 3jPdf6yLr2h+mmuXoiQCVKRUudqSFH/ikT32IQRQYATy+VRF4dSNdLlMDlWNnxqm8v /8/LpjfB/aerA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1q4HfF-0000jl-M5; Wed, 31 May 2023 10:58:41 +0200 From: Johan Hovold To: Marcel Holtmann , Johan Hedberg , Luiz Augusto von Dentz Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH RESEND 1/2] Bluetooth: fix debugfs registration Date: Wed, 31 May 2023 10:57:58 +0200 Message-Id: <20230531085759.2803-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230531085759.2803-1-johan+linaro@kernel.org> References: <20230531085759.2803-1-johan+linaro@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Since commit ec6cef9cd98d ("Bluetooth: Fix SMP channel registration for unconfigured controllers") the debugfs interface for unconfigured controllers will be created when the controller is configured. There is however currently nothing preventing a controller from being configured multiple time (e.g. setting the device address using btmgmt) which results in failed attempts to register the already registered debugfs entries: debugfs: File 'features' in directory 'hci0' already present! debugfs: File 'manufacturer' in directory 'hci0' already present! debugfs: File 'hci_version' in directory 'hci0' already present! ... debugfs: File 'quirk_simultaneous_discovery' in directory 'hci0' already present! Add a controller flag to avoid trying to register the debugfs interface more than once. Fixes: ec6cef9cd98d ("Bluetooth: Fix SMP channel registration for unconfigured controllers") Cc: stable@vger.kernel.org # 4.0 Signed-off-by: Johan Hovold --- include/net/bluetooth/hci.h | 1 + net/bluetooth/hci_sync.c | 3 +++ 2 files changed, 4 insertions(+) diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 07df96c47ef4..872dcb91a540 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h @@ -350,6 +350,7 @@ enum { enum { HCI_SETUP, HCI_CONFIG, + HCI_DEBUGFS_CREATED, HCI_AUTO_OFF, HCI_RFKILLED, HCI_MGMT, diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index 647a8ce54062..0efc2253265e 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -4543,6 +4543,9 @@ static int hci_init_sync(struct hci_dev *hdev) !hci_dev_test_flag(hdev, HCI_CONFIG)) return 0; + if (hci_dev_test_and_set_flag(hdev, HCI_DEBUGFS_CREATED)) + return 0; + hci_debugfs_create_common(hdev); if (lmp_bredr_capable(hdev))