Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: hci_uart: fix race during initialization

'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>

authored by

Arseniy Krasnov and committed by
Luiz Augusto von Dentz
366ceff4 bb3569ac

+2 -1
+2 -1
drivers/bluetooth/hci_ldisc.c
··· 707 707 708 708 hu->proto = p; 709 709 710 + set_bit(HCI_UART_PROTO_READY, &hu->flags); 711 + 710 712 err = hci_uart_register_dev(hu); 711 713 if (err) { 712 714 return err; 713 715 } 714 716 715 - set_bit(HCI_UART_PROTO_READY, &hu->flags); 716 717 return 0; 717 718 } 718 719