From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 87C951E3776; Mon, 21 Oct 2024 10:47:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729507663; cv=none; b=F+NWAw22LbTdql9CidWi+wk0Ks2aibT3lLlheylYa/PVyCDqOuianJqODMKWY4VnIiRDDod+EPoE0fhem5y8rHu1MQQsbLF6ZuyKS5T6b/MydZict5FY1MejQE0ymCtld/nWU6jceQQrQuMVqhuFV6gsN0GqvOAA6Lr9q6nAol0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729507663; c=relaxed/simple; bh=hVdkqtkXEF1HSTBEYueFe+1WjKbhi6RdxTCHp2Zhw5g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ey8mNPjnhUQk3nfkkQnduYQoflAtcJuVRbMJDGy3AjcAoJRCdM7oJp+clGiMTtJvjoX+eDz0StkuQrDgUPxZR9azeLV+HMjgjG5I/YPqGfnDVGcxzozPSOd8xuxobIMid9I86KtJCqPbjFoluuO2GvXy5sV4MFqyX/xQulh+2ow= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=GII3n5+q; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="GII3n5+q" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 069C2C4CEC3; Mon, 21 Oct 2024 10:47:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1729507663; bh=hVdkqtkXEF1HSTBEYueFe+1WjKbhi6RdxTCHp2Zhw5g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GII3n5+qJ+dtzVxhX5qZiIDXXpEiyBykpndPZSjF4T5Ceza4sdj0rT+twDvzYEHWc +VBaIQkA+px1Tfsyq9O7hTlzS7FzoIb4qMOlS6y/lPCMXdmdosDZPtWBcRScoZFpbm /Nj2br8BWO75mY8yI1kCtJBOJPMSm0kH2uCDI/Nc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Aaron Thompson , Luiz Augusto von Dentz Subject: [PATCH 5.15 61/82] Bluetooth: Remove debugfs directory on module init failure Date: Mon, 21 Oct 2024 12:25:42 +0200 Message-ID: <20241021102249.641629058@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241021102247.209765070@linuxfoundation.org> References: <20241021102247.209765070@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Aaron Thompson commit 1db4564f101b47188c1b71696bd342ef09172b22 upstream. If bt_init() fails, the debugfs directory currently is not removed. If the module is loaded again after that, the debugfs directory is not set up properly due to the existing directory. # modprobe bluetooth # ls -laF /sys/kernel/debug/bluetooth total 0 drwxr-xr-x 2 root root 0 Sep 27 14:26 ./ drwx------ 31 root root 0 Sep 27 14:25 ../ -r--r--r-- 1 root root 0 Sep 27 14:26 l2cap -r--r--r-- 1 root root 0 Sep 27 14:26 sco # modprobe -r bluetooth # ls -laF /sys/kernel/debug/bluetooth ls: cannot access '/sys/kernel/debug/bluetooth': No such file or directory # # modprobe bluetooth modprobe: ERROR: could not insert 'bluetooth': Invalid argument # dmesg | tail -n 6 Bluetooth: Core ver 2.22 NET: Registered PF_BLUETOOTH protocol family Bluetooth: HCI device and connection manager initialized Bluetooth: HCI socket layer initialized Bluetooth: Faking l2cap_init() failure for testing NET: Unregistered PF_BLUETOOTH protocol family # ls -laF /sys/kernel/debug/bluetooth total 0 drwxr-xr-x 2 root root 0 Sep 27 14:31 ./ drwx------ 31 root root 0 Sep 27 14:26 ../ # # modprobe bluetooth # dmesg | tail -n 7 Bluetooth: Core ver 2.22 debugfs: Directory 'bluetooth' with parent '/' already present! NET: Registered PF_BLUETOOTH protocol family Bluetooth: HCI device and connection manager initialized Bluetooth: HCI socket layer initialized Bluetooth: L2CAP socket layer initialized Bluetooth: SCO socket layer initialized # ls -laF /sys/kernel/debug/bluetooth total 0 drwxr-xr-x 2 root root 0 Sep 27 14:31 ./ drwx------ 31 root root 0 Sep 27 14:26 ../ # Cc: stable@vger.kernel.org Fixes: ffcecac6a738 ("Bluetooth: Create root debugfs directory during module init") Signed-off-by: Aaron Thompson Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Greg Kroah-Hartman --- net/bluetooth/af_bluetooth.c | 1 + 1 file changed, 1 insertion(+) --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c @@ -779,6 +779,7 @@ cleanup_sysfs: bt_sysfs_cleanup(); cleanup_led: bt_leds_cleanup(); + debugfs_remove_recursive(bt_debugfs); return err; }