* [PATCH v2] Bluetooth: fix memory leak in error path of hci_alloc_dev()
@ 2026-05-31 16:30 Bharath Reddy
2026-05-31 17:23 ` [v2] " bluez.test.bot
2026-05-31 18:13 ` [PATCH v2] " Markus Elfring
0 siblings, 2 replies; 3+ messages in thread
From: Bharath Reddy @ 2026-05-31 16:30 UTC (permalink / raw)
To: marcel, luiz.dentz
Cc: linux-bluetooth, linux-kernel, Bharath Reddy,
syzbot+535ecc844591e50588a5
Early failures in Bluetooth HCI UART configuration leak SRCU percpu
memory.
When device initialization fails before hci_register_dev() completes,
the HCI_UNREGISTER flag is never set. As a result, when the device
reference count reaches zero, bt_host_release() evaluates this flag as
false and falls back to a direct kfree(hdev).
Because hci_release_dev() is bypassed, the SRCU struct initialized
early in hci_alloc_dev() is never cleaned up, resulting in a leak of
percpu memory.
Fix the leak by explicitly calling cleanup_srcu_struct() in the
fallback (unregistered) branch of bt_host_release() before freeing
the device.
Reported-by: syzbot+535ecc844591e50588a5@syzkaller.appspotmail.com
Tested-by: syzbot+535ecc844591e50588a5@syzkaller.appspotmail.com
Signed-off-by: Bharath Reddy <kbreddy.rpbc@gmail.com>
---
net/bluetooth/hci_sysfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 041ce9adc378..74131f2c3be6 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -85,8 +85,10 @@ static void bt_host_release(struct device *dev)
if (hci_dev_test_flag(hdev, HCI_UNREGISTER))
hci_release_dev(hdev);
- else
+ else {
+ cleanup_srcu_struct(&hdev->srcu);
kfree(hdev);
+ }
module_put(THIS_MODULE);
}
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* RE: [v2] Bluetooth: fix memory leak in error path of hci_alloc_dev()
2026-05-31 16:30 [PATCH v2] Bluetooth: fix memory leak in error path of hci_alloc_dev() Bharath Reddy
@ 2026-05-31 17:23 ` bluez.test.bot
2026-05-31 18:13 ` [PATCH v2] " Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-05-31 17:23 UTC (permalink / raw)
To: linux-bluetooth, kbreddy.rpbc
[-- Attachment #1: Type: text/plain, Size: 3229 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1103634
---Test result---
Test Summary:
CheckPatch FAIL 0.60 seconds
VerifyFixes PASS 0.09 seconds
VerifySignedoff PASS 0.11 seconds
GitLint PASS 0.24 seconds
SubjectPrefix PASS 0.08 seconds
BuildKernel PASS 24.95 seconds
CheckAllWarning PASS 27.43 seconds
CheckSparse PASS 26.70 seconds
BuildKernel32 PASS 24.35 seconds
TestRunnerSetup PASS 520.47 seconds
TestRunner_l2cap-tester PASS 57.78 seconds
TestRunner_iso-tester PASS 74.71 seconds
TestRunner_bnep-tester PASS 19.35 seconds
TestRunner_mgmt-tester FAIL 210.09 seconds
TestRunner_rfcomm-tester PASS 25.18 seconds
TestRunner_sco-tester PASS 32.15 seconds
TestRunner_ioctl-tester PASS 26.43 seconds
TestRunner_mesh-tester FAIL 25.90 seconds
TestRunner_smp-tester PASS 23.34 seconds
TestRunner_userchan-tester PASS 20.13 seconds
TestRunner_6lowpan-tester PASS 22.82 seconds
IncrementalBuild PASS 23.50 seconds
Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[v2] Bluetooth: fix memory leak in error path of hci_alloc_dev()
WARNING: Reported-by: should be immediately followed by Closes: with a URL to the report
#116:
Reported-by: syzbot+535ecc844591e50588a5@syzkaller.appspotmail.com
Tested-by: syzbot+535ecc844591e50588a5@syzkaller.appspotmail.com
CHECK: Unbalanced braces around else statement
#132: FILE: net/bluetooth/hci_sysfs.c:88:
+ else {
WARNING: The commit message has 'syzkaller', perhaps it also needs a 'Fixes:' tag?
total: 0 errors, 2 warnings, 1 checks, 11 lines checked
NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.
/github/workspace/src/patch/14603853.patch has style problems, please review.
NOTE: Ignored message types: UNKNOWN_COMMIT_ID
NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner
Output:
Total: 494, Passed: 489 (99.0%), Failed: 1, Not Run: 4
Failed Test Cases
Read Exp Feature - Success Failed 0.236 seconds
##############################
Test: TestRunner_mesh-tester - FAIL
Desc: Run mesh-tester with test-runner
Output:
Total: 10, Passed: 8 (80.0%), Failed: 2, Not Run: 0
Failed Test Cases
Mesh - Send cancel - 1 Timed out 2.331 seconds
Mesh - Send cancel - 2 Timed out 1.991 seconds
https://github.com/bluez/bluetooth-next/pull/260
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] Bluetooth: fix memory leak in error path of hci_alloc_dev()
2026-05-31 16:30 [PATCH v2] Bluetooth: fix memory leak in error path of hci_alloc_dev() Bharath Reddy
2026-05-31 17:23 ` [v2] " bluez.test.bot
@ 2026-05-31 18:13 ` Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2026-05-31 18:13 UTC (permalink / raw)
To: Bharath Reddy, linux-bluetooth, Luiz Von Dentz, Marcel Holtmann
Cc: syzbot+535ecc844591e50588a5, LKML
…
> Fix the leak by explicitly calling cleanup_srcu_struct() in the
> fallback (unregistered) branch of bt_host_release() before freeing
> the device.
…
> ---
> net/bluetooth/hci_sysfs.c | 4 +++-
Some contributors would appreciate patch version descriptions.
https://lore.kernel.org/all/?q=%22This+looks+like+a+new+version+of+a+previously+submitted+patch%22
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.1-rc5#n310
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-31 18:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-31 16:30 [PATCH v2] Bluetooth: fix memory leak in error path of hci_alloc_dev() Bharath Reddy
2026-05-31 17:23 ` [v2] " bluez.test.bot
2026-05-31 18:13 ` [PATCH v2] " Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox