Skip to content

Commit 613a1c0

Browse files
finikorgGustavo F. Padovan
authored andcommitted
Bluetooth: Clean up magic pointers
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
1 parent 32ac5b9 commit 613a1c0

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎include/net/bluetooth/hci.h‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -979,9 +979,14 @@ struct hci_ev_role_change {
979979
} __packed;
980980

981981
#define HCI_EV_NUM_COMP_PKTS 0x13
982+
struct hci_comp_pkts_info {
983+
__le16 handle;
984+
__le16 count;
985+
} __packed;
986+
982987
struct hci_ev_num_comp_pkts {
983988
__u8 num_hndl;
984-
/* variable length part */
989+
struct hci_comp_pkts_info handles[0];
985990
} __packed;
986991

987992
#define HCI_EV_MODE_CHANGE 0x14

‎net/bluetooth/hci_event.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,7 +2256,6 @@ static inline void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb
22562256
static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb)
22572257
{
22582258
struct hci_ev_num_comp_pkts *ev = (void *) skb->data;
2259-
__le16 *ptr;
22602259
int i;
22612260

22622261
skb_pull(skb, sizeof(*ev));
@@ -2273,12 +2272,13 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s
22732272
return;
22742273
}
22752274

2276-
for (i = 0, ptr = (__le16 *) skb->data; i < ev->num_hndl; i++) {
2275+
for (i = 0; i < ev->num_hndl; i++) {
2276+
struct hci_comp_pkts_info *info = &ev->handles[i];
22772277
struct hci_conn *conn;
22782278
__u16 handle, count;
22792279

2280-
handle = get_unaligned_le16(ptr++);
2281-
count = get_unaligned_le16(ptr++);
2280+
handle = __le16_to_cpu(info->handle);
2281+
count = __le16_to_cpu(info->count);
22822282

22832283
conn = hci_conn_hash_lookup_handle(hdev, handle);
22842284
if (!conn)

0 commit comments

Comments
 (0)