[PATCH] Bluetooth: btnxpuart: unregister HCI device on probe failure
From: Neeraj Sanjay Kale
Date: Fri Jun 26 2026 - 05:12:28 EST
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@xxxxxx/
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@xxxxxxxxx>
> Signed-off-by: Ijae Kim <ae878000@xxxxxxxxx>
> Signed-off-by: Myeonghun Pak <mhun512@xxxxxxxxx>
> ---
> 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