]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
Bluetooth: hci_uart: fix race during initialization
authorArseniy Krasnov <avkrasnov@salutedevices.com>
Thu, 30 Jan 2025 18:43:26 +0000 (21:43 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Apr 2025 08:45:17 +0000 (10:45 +0200)
commit806464634e7fc6b523160defeeddb1ade2a72f81
tree0770d445ac7248eb277d054a89120ded324d5733
parente711501970a02e39cea48e08e1e3a6aeb0fdd603
Bluetooth: hci_uart: fix race during initialization

[ Upstream commit 366ceff495f902182d42b6f41525c2474caf3f9a ]

'hci_register_dev()' calls power up function, which is executed by
kworker - 'hci_power_on()'. This function does access to bluetooth chip
using callbacks from 'hci_ldisc.c', for example 'hci_uart_send_frame()'.
Now 'hci_uart_send_frame()' checks 'HCI_UART_PROTO_READY' bit set, and
if not - it fails. Problem is that 'HCI_UART_PROTO_READY' is set after
'hci_register_dev()', and there is tiny chance that 'hci_power_on()' will
be executed before setting this bit. In that case HCI init logic fails.

Patch moves setting of 'HCI_UART_PROTO_READY' before calling function
'hci_uart_register_dev()'.

Signed-off-by: Arseniy Krasnov <avkrasnov@salutedevices.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/bluetooth/hci_ldisc.c