Skip to contentSkip to conversation

Bluetooth: Use the updated key structures for handling LTKs

DISCUSSION Dan Carpenter 2 participants 2 messages Mar 7, 2012 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hello Vinicius Costa Gomes,

The patch c9839a11c0e4: "Bluetooth: Use the updated key structures for handling LTKs" from Feb 2, 2012, leads to the following Sparse
warning: net/bluetooth/mgmt.c:2590:59: warning: incorrect type in argument 9 (different base types)

+int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type,
+ int new_key, u8 authenticated, u8 tk[16],

+                               u8 enc_size, u16 ediv, u8 rand[8]);
                                             ^^^^^^^^

+struct smp_ltk *hci_find_ltk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr,
+ u8 addr_type);
int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr);
-int hci_add_ltk(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr,

-                       u8 key_size, __le16 ediv, u8 rand[8], u8 ltk[16]);
                                     ^^^^^^^^^^^

int hci_smp_ltks_clear(struct hci_dev *hdev);

We removed the endian notation from ediv, but it seems from a quick read that the __le16 was correct. Btw, here is an article on how to use Sparse to find endian bugs: http://lwn.net/Articles/205624/

regards,
dan carpenter

#1 lore raw

Hi Dan,

Quoted 8 lines · Dan Carpenter

Hello Vinicius Costa Gomes,

The patch c9839a11c0e4: "Bluetooth: Use the updated key structures for handling LTKs" from Feb 2, 2012, leads to the following Sparse
warning: net/bluetooth/mgmt.c:2590:59: warning: incorrect type in argument 9 (different base types)

(quoted diff) +1 -0
+int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type,

Review

Quoted 10 lines
(quoted diff) +4 -2
+                               int new_key, u8 authenticated, u8 tk[16],
+                               u8 enc_size, u16 ediv, u8 rand[8]);
                                             ^^^^^^^^
+struct smp_ltk *hci_find_ltk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr,
+                                                               u8 addr_type);
 int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr);
-int hci_add_ltk(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr,
-                       u8 key_size, __le16 ediv, u8 rand[8], u8 ltk[16]);
                                     ^^^^^^^^^^^
 int hci_smp_ltks_clear(struct hci_dev *hdev);

Thanks for the heads up, will fix it.

Quoted 5 lines

We removed the endian notation from ediv, but it seems from a quick read that the __le16 was correct. Btw, here is an article on how to use Sparse to find endian bugs: http://lwn.net/Articles/205624/

Quoted 7 lines

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Cheers,

Signature · 1 line
Vinicius