Bluetooth: hci_ll: Add endianness conversion when setting baudrate
authorDavid Lechner <david@lechnology.com>
Fri, 8 Dec 2017 02:22:19 +0000 (20:22 -0600)
committerMarcel Holtmann <marcel@holtmann.org>
Tue, 12 Dec 2017 23:28:41 +0000 (00:28 +0100)
This adds an endianness conversion when setting the baudrate using a
vendor-specific command. Otherwise, bad things might happen on a big-
endian system.

Suggested-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: David Lechner <david@lechnology.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/hci_ll.c

index 974a78879d2062ab47fc0fa48f6786fca9dfb317..efcfbe9aac21792a63fe9e4f40a0e289de9db95c 100644 (file)
@@ -707,10 +707,12 @@ static int ll_setup(struct hci_uart *hu)
                speed = 0;
 
        if (speed) {
+               __le32 speed_le = cpu_to_le32(speed);
                struct sk_buff *skb;
 
                skb = __hci_cmd_sync(hu->hdev, HCI_VS_UPDATE_UART_HCI_BAUDRATE,
-                                    sizeof(speed), &speed, HCI_INIT_TIMEOUT);
+                                    sizeof(speed_le), &speed_le,
+                                    HCI_INIT_TIMEOUT);
                if (!IS_ERR(skb)) {
                        kfree_skb(skb);
                        serdev_device_set_baudrate(serdev, speed);