Bluetooth: fix error handling in hci_register_dev()
Subsystems (3)
PATCH 1/1 Bluetooth: fix error handling in hci_register_dev()
Once device_add() failed, we should call put_device() to decrement reference count for cleanup. Or it could cause memory leak.
As comment of device_add() says, 'if device_add() succeeds, you should call device_del() when you want to get rid of it. If device_add() has not succeeded, use only put_device() to drop the reference count'.
Found by code review.
--- net/bluetooth/hci_core.c | 1 + 1 file changed, 1 insertion(+)
net/bluetooth/hci_core.c +1 -0
@@ -2641,6 +2641,7 @@ int hci_register_dev(struct hci_dev *hdev)return id; err_wqueue: +put_device (&hdev->dev);debugfs_remove_recursive (hdev->debugfs);destroy_workqueue (hdev->workqueue);destroy_workqueue (hdev->req_workqueue);
Signature · 1 line
2.25.1
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=943428
---Test result---
Test Summary:
CheckPatch PENDING 0.21 seconds GitLint PENDING 0.20 seconds SubjectPrefix PASS 0.16 seconds BuildKernel PASS 24.50 seconds CheckAllWarning PASS 26.75 seconds CheckSparse PASS 30.48 seconds BuildKernel32 PASS 24.14 seconds TestRunnerSetup PASS 430.89 seconds TestRunner_l2cap-tester PASS 20.89 seconds TestRunner_iso-tester PASS 30.42 seconds TestRunner_bnep-tester PASS 4.76 seconds TestRunner_mgmt-tester FAIL 121.30 seconds TestRunner_rfcomm-tester PASS 7.86 seconds TestRunner_sco-tester PASS 12.20 seconds TestRunner_ioctl-tester PASS 8.50 seconds TestRunner_mesh-tester PASS 5.98 seconds TestRunner_smp-tester PASS 8.92 seconds TestRunner_userchan-tester PASS 5.03 seconds IncrementalBuild PENDING 0.76 seconds
Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script Output:
##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:
##############################
Test: TestRunner_mgmt-tester - FAIL
Desc: Run mgmt-tester with test-runner Output:
Total: 490, Passed: 485 (99.0%), Failed: 1, Not Run: 4
Failed Test Cases
LL Privacy - Start Discovery 2 (Disable RL) Failed 0.184 seconds
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series Output:
---
Regards,
Linux Bluetooth
Greg KH
maintainerQuoted 21 lines · Ma Ke
Once
device_add()failed, we should callput_device()to decrement reference count for cleanup. Or it could cause memory leak.As comment of
device_add()says, 'ifdevice_add()succeeds, you should calldevice_del()when you want to get rid of it. Ifdevice_add()has not succeeded, use onlyput_device()to drop the reference count'.Found by code review.
Fixes 54506918059a ("Bluetooth: Move SMP initialization after HCI init")Signed-off-by Ma Ke <[email protected]>--- net/bluetooth/hci_core.c | 1 + 1 file changed, 1 insertion(+)net/bluetooth/hci_core.c +0
-0
net/bluetooth/hci_core.c int hci_register_dev(struct hci_dev *hdev) · line 2644
Quoted 4 lines
net/bluetooth/hci_core.c +1
-0@@ -2641,6 +2641,7 @@ int hci_register_dev(struct hci_dev *hdev)return id; err_wqueue: +put_device (&hdev->dev);
How was this tested?