summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorZhao Dongdong <zhaodongdong@kylinos.cn>2026-05-15 08:46:07 +0800
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2026-08-07 12:34:41 -0400
commita2b3b4f00403a3a40c5627d1bf537c8fb166e221 (patch)
treee56387f3457639c4541ece3d1f647bc309087fcc /drivers
parent6f0624b4427e38c3bb63a951c536cf8adaee1238 (diff)
downloadlinux-a2b3b4f00403a3a40c5627d1bf537c8fb166e221.tar.gz
linux-a2b3b4f00403a3a40c5627d1bf537c8fb166e221.zip
Bluetooth: btnxpuart: Fix use-after-free in probe error path
In nxp_serdev_probe(), if hci_register_dev() succeeds but ps_setup() fails, the error path jumps to 'probe_fail' which only calls hci_free_dev() and asserts the reset GPIO, but does NOT call hci_unregister_dev() first. This leaves the HCI device registered in the system with its backing memory freed, leading to a use-after-free when userspace subsequently accesses the device (e.g. via hciconfig or bluetoothd). Fix by adding a 'probe_fail_unregister' label that calls hci_unregister_dev() before falling through to the existing 'probe_fail' label. The original 'probe_fail' label is preserved for the case where hci_register_dev() itself fails (device was never registered, so no unregister is needed). Signed-off-by: Zhao Dongdong <zhaodongdong@kylinos.cn> Reviewed-by: Neeraj Sanjay Kale <neeraj.sanjaykale@nxp.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/bluetooth/btnxpuart.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/bluetooth/btnxpuart.c b/drivers/bluetooth/btnxpuart.c
index 6a1cffe08d5f..0bb300eef157 100644
--- a/drivers/bluetooth/btnxpuart.c
+++ b/drivers/bluetooth/btnxpuart.c
@@ -1913,13 +1913,15 @@ static int nxp_serdev_probe(struct serdev_device *serdev)
}
if (ps_setup(hdev))
- goto probe_fail;
+ goto probe_fail_unregister;
hci_devcd_register(hdev, nxp_coredump, nxp_coredump_hdr,
nxp_coredump_notify);
return 0;
+probe_fail_unregister:
+ hci_unregister_dev(hdev);
probe_fail:
reset_control_assert(nxpdev->pdn);
hci_free_dev(hdev);