aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth/hci_uart.h
diff options
context:
space:
mode:
authorDean Jenkins <Dean_Jenkins@mentor.com>2017-05-05 16:27:06 +0100
committerMarcel Holtmann <marcel@holtmann.org>2017-05-18 13:52:50 +0200
commitdec2c92880cc5435381d50e3045ef018a762a917 (patch)
tree3312e3a68788b6dd49d292dafdc38ae11b6ae1ee /drivers/bluetooth/hci_uart.h
parentBluetooth: Skip vendor diagnostic configuration for HCI User Channel (diff)
downloadlinux-dev-dec2c92880cc5435381d50e3045ef018a762a917.tar.xz
linux-dev-dec2c92880cc5435381d50e3045ef018a762a917.zip
Bluetooth: hci_ldisc: Use rwlocking to avoid closing proto races
When HCI_UART_PROTO_READY is in the set state, the Data Link protocol layer (proto) is bound to the HCI UART driver. This state allows the registered proto function pointers to be used by the HCI UART driver. When unbinding (closing) the Data Link protocol layer, the proto function pointers much be prevented from being used immediately before running the proto close function pointer. Otherwise, there is a risk that a proto non-close function pointer is used during or after the proto close function pointer is used. The consequences are likely to be a kernel crash because the proto close function pointer will free resources used in the Data Link protocol layer. Therefore, add a reader writer lock (rwlock) solution to prevent the close proto function pointer from running by using write_lock_irqsave() whilst the other proto function pointers are protected using read_lock(). This means HCI_UART_PROTO_READY can safely be cleared in the knowledge that no proto function pointers are running. When flag HCI_UART_PROTO_READY is put into the clear state, proto close function pointer can safely be run. Note flag HCI_UART_PROTO_SET being in the set state prevents the proto open function pointer from being run so there is no race condition between proto open and close function pointers. Signed-off-by: Dean Jenkins <Dean_Jenkins@mentor.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'drivers/bluetooth/hci_uart.h')
-rw-r--r--drivers/bluetooth/hci_uart.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
index 2b05e557fad0..c6e9e1cf63f8 100644
--- a/drivers/bluetooth/hci_uart.h
+++ b/drivers/bluetooth/hci_uart.h
@@ -87,6 +87,7 @@ struct hci_uart {
struct work_struct write_work;
const struct hci_uart_proto *proto;
+ rwlock_t proto_lock; /* Stop work for proto close */
void *priv;
struct sk_buff *tx_skb;