Bluetooth: Fix passkey endianess in user_confirm and notify_passkey
authorJohan Hedberg <johan.hedberg@intel.com>
Thu, 20 Mar 2014 06:18:14 +0000 (08:18 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 20 Mar 2014 06:22:07 +0000 (23:22 -0700)
The passkey_notify and user_confirm functions in mgmt.c were expecting
different endianess for the passkey, leading to a big endian bug and
sparse warning in recently added SMP code. This patch converts both
functions to expect host endianess and do the conversion to little
endian only when assigning to the mgmt event struct.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
include/net/bluetooth/hci_core.h
net/bluetooth/hci_event.c
net/bluetooth/mgmt.c
net/bluetooth/smp.c

index b8cc39a4a9a547fbffeb2441e84725d82edfae9d..afbea388eda1ccb245bdff92f3f2cee51b22e452 100644 (file)
@@ -1236,7 +1236,7 @@ void mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
 void mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
                                      u8 status);
 int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr,
-                             u8 link_type, u8 addr_type, __le32 value,
+                             u8 link_type, u8 addr_type, u32 value,
                              u8 confirm_hint);
 int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
                                     u8 link_type, u8 addr_type, u8 status);
index a6a3d32553c5849f3f7f4206df7780404ef57757..1e386edc338f831049d1c294a316f94ae0c7cfcf 100644 (file)
@@ -3459,8 +3459,8 @@ static void hci_user_confirm_request_evt(struct hci_dev *hdev,
        }
 
 confirm:
-       mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0, ev->passkey,
-                                 confirm_hint);
+       mgmt_user_confirm_request(hdev, &ev->bdaddr, ACL_LINK, 0,
+                                 le32_to_cpu(ev->passkey), confirm_hint);
 
 unlock:
        hci_dev_unlock(hdev);
index 96670f581bb09cd1d0577aae700eca5aa33db767..739887c6b286dcc4e3ce57817ca3ccc76700bd14 100644 (file)
@@ -5338,7 +5338,7 @@ void mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr,
 }
 
 int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr,
-                             u8 link_type, u8 addr_type, __le32 value,
+                             u8 link_type, u8 addr_type, u32 value,
                              u8 confirm_hint)
 {
        struct mgmt_ev_user_confirm_request ev;
@@ -5348,7 +5348,7 @@ int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr,
        bacpy(&ev.addr.bdaddr, bdaddr);
        ev.addr.type = link_to_bdaddr(link_type, addr_type);
        ev.confirm_hint = confirm_hint;
-       ev.value = value;
+       ev.value = cpu_to_le32(value);
 
        return mgmt_event(MGMT_EV_USER_CONFIRM_REQUEST, hdev, &ev, sizeof(ev),
                          NULL);
index 2a7ee7f6cd8ba4507337dc8ed2edf6027f418d9b..13919ff82e055f51f0eb32ce0c1f1fa94b105c91 100644 (file)
@@ -425,7 +425,7 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth,
        else
                ret = mgmt_user_passkey_notify(hcon->hdev, &hcon->dst,
                                                hcon->type, hcon->dst_type,
-                                               cpu_to_le32(passkey), 0);
+                                               passkey, 0);
 
        hci_dev_unlock(hcon->hdev);