Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btnxpuart: unregister HCI device on probe failure
@ 2026-06-26  8:55 Myeonghun Pak
  2026-06-26  9:06 ` Neeraj Sanjay Kale
  2026-06-26 11:26 ` bluez.test.bot
  0 siblings, 2 replies; 4+ messages in thread
From: Myeonghun Pak @ 2026-06-26  8:55 UTC (permalink / raw)
  To: Amitkumar Karwar, Neeraj Kale, Marcel Holtmann,
	Luiz Augusto von Dentz
  Cc: linux-bluetooth, linux-kernel, Myeonghun Pak, Ijae Kim

If hci_register_dev() succeeds but ps_setup() fails, nxp_serdev_probe()
jumps to probe_fail and frees the HCI device without first unregistering
it. The remove path unregisters the HCI device before freeing it, and the
probe error path needs the same ordering once registration has succeeded.

Send failures after successful registration through a new label that calls
hci_unregister_dev(), then fall through to the existing reset and free
cleanup. Keep hci_register_dev() failures on the original path because the
device was not registered in that case.

Fixes: 689ca16e5232 ("Bluetooth: NXP: Add protocol support for NXP Bluetooth chipsets")
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
---
 drivers/bluetooth/btnxpuart.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
index e7036a48ce..6778b883ab 100644
--- a/drivers/bluetooth/btnxpuart.c
+++ b/drivers/bluetooth/btnxpuart.c
@@ -1907,13 +1907,15 @@ static int nxp_serdev_probe(struct serdev_device *serdev)
 	}
 
 	if (ps_setup(hdev))
-		goto probe_fail;
+		goto unregister_dev;
 
 	hci_devcd_register(hdev, nxp_coredump, nxp_coredump_hdr,
 			   nxp_coredump_notify);
 
 	return 0;
 
+unregister_dev:
+	hci_unregister_dev(hdev);
 probe_fail:
 	reset_control_assert(nxpdev->pdn);
 	hci_free_dev(hdev);
-- 
2.53.0


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

* [PATCH] Bluetooth: btnxpuart: unregister HCI device on probe failure
  2026-06-26  8:55 [PATCH] Bluetooth: btnxpuart: unregister HCI device on probe failure Myeonghun Pak
@ 2026-06-26  9:06 ` Neeraj Sanjay Kale
  2026-06-26  9:10   ` Myeonghun Pak
  2026-06-26 11:26 ` bluez.test.bot
  1 sibling, 1 reply; 4+ messages in thread
From: Neeraj Sanjay Kale @ 2026-06-26  9:06 UTC (permalink / raw)
  To: Myeonghun Pak, Amitkumar Karwar, Marcel Holtmann,
	Luiz Augusto von Dentz
  Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ijae Kim, zhaodongdong@kylinos.cn

Hi Myeonghun,

Thank you for submitting this patch.

However, a similar patch is already in review and approved by me:
https://patchwork.kernel.org/project/bluetooth/patch/tencent_F2E2AF1B6F510577B10C6897ED768BBBAF07@qq.com/
It's awaiting Luiz's review and/or merge.


Hi Luiz,

Can you please review the patch mentioned in the URL above, from Zhao Dongdong? I have answered your review comment.
Thank you for your time and review.

Thanks,
Neeraj


> If hci_register_dev() succeeds but ps_setup() fails, nxp_serdev_probe() jumps
> to probe_fail and frees the HCI device without first unregistering it. The
> remove path unregisters the HCI device before freeing it, and the probe error
> path needs the same ordering once registration has succeeded.
> 
> Send failures after successful registration through a new label that calls
> hci_unregister_dev(), then fall through to the existing reset and free cleanup.
> Keep hci_register_dev() failures on the original path because the device was
> not registered in that case.
> 
> Fixes: 689ca16e5232 ("Bluetooth: NXP: Add protocol support for NXP
> Bluetooth chipsets")
> Co-developed-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
> ---
>  drivers/bluetooth/btnxpuart.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
> index e7036a48ce..6778b883ab 100644
> --- a/drivers/bluetooth/btnxpuart.c
> +++ b/drivers/bluetooth/btnxpuart.c
> @@ -1907,13 +1907,15 @@ static int nxp_serdev_probe(struct serdev_device
> *serdev)
>         }
> 
>         if (ps_setup(hdev))
> -               goto probe_fail;
> +               goto unregister_dev;
> 
>         hci_devcd_register(hdev, nxp_coredump, nxp_coredump_hdr,
>                            nxp_coredump_notify);
> 
>         return 0;
> 
> +unregister_dev:
> +       hci_unregister_dev(hdev);
>  probe_fail:
>         reset_control_assert(nxpdev->pdn);
>         hci_free_dev(hdev);
> --
> 2.53.0


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

* Re: [PATCH] Bluetooth: btnxpuart: unregister HCI device on probe failure
  2026-06-26  9:06 ` Neeraj Sanjay Kale
@ 2026-06-26  9:10   ` Myeonghun Pak
  0 siblings, 0 replies; 4+ messages in thread
From: Myeonghun Pak @ 2026-06-26  9:10 UTC (permalink / raw)
  To: Neeraj Sanjay Kale
  Cc: Amitkumar Karwar, Marcel Holtmann, Luiz Augusto von Dentz,
	linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ijae Kim, zhaodongdong@kylinos.cn

Hi Neeraj,

Thank you for checking and for pointing me to Zhao's patch.

I missed that pending review. Please ignore my patch; I will defer to the
existing patch from Zhao Dongdong.

Sorry for the noise.

Best regards,
Myeonghun

2026년 6월 26일 (금) 오후 6:07, Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com>님이 작성:
>
> Hi Myeonghun,
>
> Thank you for submitting this patch.
>
> However, a similar patch is already in review and approved by me:
> https://patchwork.kernel.org/project/bluetooth/patch/tencent_F2E2AF1B6F510577B10C6897ED768BBBAF07@qq.com/
> It's awaiting Luiz's review and/or merge.
>
>
> Hi Luiz,
>
> Can you please review the patch mentioned in the URL above, from Zhao Dongdong? I have answered your review comment.
> Thank you for your time and review.
>
> Thanks,
> Neeraj
>
>
> > If hci_register_dev() succeeds but ps_setup() fails, nxp_serdev_probe() jumps
> > to probe_fail and frees the HCI device without first unregistering it. The
> > remove path unregisters the HCI device before freeing it, and the probe error
> > path needs the same ordering once registration has succeeded.
> >
> > Send failures after successful registration through a new label that calls
> > hci_unregister_dev(), then fall through to the existing reset and free cleanup.
> > Keep hci_register_dev() failures on the original path because the device was
> > not registered in that case.
> >
> > Fixes: 689ca16e5232 ("Bluetooth: NXP: Add protocol support for NXP
> > Bluetooth chipsets")
> > Co-developed-by: Ijae Kim <ae878000@gmail.com>
> > Signed-off-by: Ijae Kim <ae878000@gmail.com>
> > Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
> > ---
> >  drivers/bluetooth/btnxpuart.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
> > index e7036a48ce..6778b883ab 100644
> > --- a/drivers/bluetooth/btnxpuart.c
> > +++ b/drivers/bluetooth/btnxpuart.c
> > @@ -1907,13 +1907,15 @@ static int nxp_serdev_probe(struct serdev_device
> > *serdev)
> >         }
> >
> >         if (ps_setup(hdev))
> > -               goto probe_fail;
> > +               goto unregister_dev;
> >
> >         hci_devcd_register(hdev, nxp_coredump, nxp_coredump_hdr,
> >                            nxp_coredump_notify);
> >
> >         return 0;
> >
> > +unregister_dev:
> > +       hci_unregister_dev(hdev);
> >  probe_fail:
> >         reset_control_assert(nxpdev->pdn);
> >         hci_free_dev(hdev);
> > --
> > 2.53.0
>

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

* RE: Bluetooth: btnxpuart: unregister HCI device on probe failure
  2026-06-26  8:55 [PATCH] Bluetooth: btnxpuart: unregister HCI device on probe failure Myeonghun Pak
  2026-06-26  9:06 ` Neeraj Sanjay Kale
@ 2026-06-26 11:26 ` bluez.test.bot
  1 sibling, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2026-06-26 11:26 UTC (permalink / raw)
  To: linux-bluetooth, mhun512

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

---Test result---

Test Summary:
CheckPatch                    PASS      1.06 seconds
VerifyFixes                   PASS      0.32 seconds
VerifySignedoff               PASS      0.26 seconds
GitLint                       PASS      0.69 seconds
SubjectPrefix                 PASS      0.26 seconds
BuildKernel                   PASS      27.29 seconds
CheckAllWarning               PASS      30.10 seconds
CheckSparse                   PASS      29.16 seconds
BuildKernel32                 PASS      26.36 seconds
CheckKernelLLVM               SKIP      0.00 seconds
TestRunnerSetup               PASS      503.86 seconds
IncrementalBuild              PASS      26.49 seconds

Details
##############################
Test: CheckKernelLLVM - SKIP
Desc: Build kernel with LLVM + context analysis
Output:
Clang not found


https://github.com/bluez/bluetooth-next/pull/355

---
Regards,
Linux Bluetooth


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

end of thread, other threads:[~2026-06-26 11:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-26  8:55 [PATCH] Bluetooth: btnxpuart: unregister HCI device on probe failure Myeonghun Pak
2026-06-26  9:06 ` Neeraj Sanjay Kale
2026-06-26  9:10   ` Myeonghun Pak
2026-06-26 11:26 ` bluez.test.bot

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