Skip to contentSkip to conversation

Bluetooth: hci_ll: Add endianness conversion when setting baudrate

PATCH In review David Lechner 2 participants 2 messages Dec 8, 2017 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: hci_ll: Add endianness conversion when setting baudrate

This adds an endianness conversion when setting the baudrate using a vendor-specific command. Otherwise, bad things might happen on a big- endian system.

---
 drivers/bluetooth/hci_ll.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/bluetooth/hci_ll.c +3 -1
index 944cdd2..486b4ea 100644
@@ -739,10 +739,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);
Signature · 1 line
2.7.4
maintainer
#1 lore raw

Hi David,

Quoted 9 lines

This adds an endianness conversion when setting the baudrate using a vendor-specific command. Otherwise, bad things might happen on a big- endian system.

---
drivers/bluetooth/hci_ll.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel