public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: fix error handling in hci_register_dev()
@ 2025-03-13  8:31 Ma Ke
  2025-03-13  9:03 ` bluez.test.bot
  2025-03-13 10:02 ` [PATCH] " Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: Ma Ke @ 2025-03-13  8:31 UTC (permalink / raw)
  To: marcel, johan.hedberg, luiz.dentz
  Cc: linux-bluetooth, linux-kernel, akpm, Ma Ke, stable

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.

Cc: stable@vger.kernel.org
Fixes: 54506918059a ("Bluetooth: Move SMP initialization after HCI init")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
---
 net/bluetooth/hci_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index e7ec12437c8b..c03fd16d3c46 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -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);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: Bluetooth: fix error handling in hci_register_dev()
  2025-03-13  8:31 [PATCH] Bluetooth: fix error handling in hci_register_dev() Ma Ke
@ 2025-03-13  9:03 ` bluez.test.bot
  2025-03-13 10:02 ` [PATCH] " Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2025-03-13  9:03 UTC (permalink / raw)
  To: linux-bluetooth, make24

[-- Attachment #1: Type: text/plain, Size: 1949 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=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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Bluetooth: fix error handling in hci_register_dev()
  2025-03-13  8:31 [PATCH] Bluetooth: fix error handling in hci_register_dev() Ma Ke
  2025-03-13  9:03 ` bluez.test.bot
@ 2025-03-13 10:02 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2025-03-13 10:02 UTC (permalink / raw)
  To: Ma Ke
  Cc: marcel, johan.hedberg, luiz.dentz, linux-bluetooth, linux-kernel,
	akpm, stable

On Thu, Mar 13, 2025 at 04:31:35PM +0800, Ma Ke wrote:
> 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.
> 
> Cc: stable@vger.kernel.org
> Fixes: 54506918059a ("Bluetooth: Move SMP initialization after HCI init")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
>  net/bluetooth/hci_core.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index e7ec12437c8b..c03fd16d3c46 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -2641,6 +2641,7 @@ int hci_register_dev(struct hci_dev *hdev)
>  	return id;
>  
>  err_wqueue:
> +	put_device(&hdev->dev);

How was this tested?


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-13 10:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-13  8:31 [PATCH] Bluetooth: fix error handling in hci_register_dev() Ma Ke
2025-03-13  9:03 ` bluez.test.bot
2025-03-13 10:02 ` [PATCH] " Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox