Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: Fixed BT ST Channel reg order

Reordered the BT ST channel registration, to make sure that the
event channel is registered before all others. This prevents a
situation where incoming events may cause kernel panic in the ST
driver if the event channel is not yet registered to handle
incoming events.In addition, the deregistration of the channels
was also modified, to be in the reversed order of the registration,
to allow the event channel to be the last one unregistered.

Signed-off-by: Chen Ganir <chen.ganir@ti.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>

authored by

Chen Ganir and committed by
Gustavo F. Padovan
8be964d2 2d20a26a

+8 -8
+8 -8
drivers/bluetooth/btwilink.c
··· 125 125 /* protocol structure registered with shared transport */ 126 126 static struct st_proto_s ti_st_proto[MAX_BT_CHNL_IDS] = { 127 127 { 128 + .chnl_id = HCI_EVENT_PKT, /* HCI Events */ 129 + .hdr_len = sizeof(struct hci_event_hdr), 130 + .offset_len_in_hdr = offsetof(struct hci_event_hdr, plen), 131 + .len_size = 1, /* sizeof(plen) in struct hci_event_hdr */ 132 + .reserve = 8, 133 + }, 134 + { 128 135 .chnl_id = HCI_ACLDATA_PKT, /* ACL */ 129 136 .hdr_len = sizeof(struct hci_acl_hdr), 130 137 .offset_len_in_hdr = offsetof(struct hci_acl_hdr, dlen), ··· 143 136 .hdr_len = sizeof(struct hci_sco_hdr), 144 137 .offset_len_in_hdr = offsetof(struct hci_sco_hdr, dlen), 145 138 .len_size = 1, /* sizeof(dlen) in struct hci_sco_hdr */ 146 - .reserve = 8, 147 - }, 148 - { 149 - .chnl_id = HCI_EVENT_PKT, /* HCI Events */ 150 - .hdr_len = sizeof(struct hci_event_hdr), 151 - .offset_len_in_hdr = offsetof(struct hci_event_hdr, plen), 152 - .len_size = 1, /* sizeof(plen) in struct hci_event_hdr */ 153 139 .reserve = 8, 154 140 }, 155 141 }; ··· 240 240 if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) 241 241 return 0; 242 242 243 - for (i = 0; i < MAX_BT_CHNL_IDS; i++) { 243 + for (i = MAX_BT_CHNL_IDS-1; i >= 0; i--) { 244 244 err = st_unregister(&ti_st_proto[i]); 245 245 if (err) 246 246 BT_ERR("st_unregister(%d) failed with error %d",