Commit 8be964d2 authored by Chen Ganir's avatar Chen Ganir Committed by Gustavo F. Padovan

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: default avatarChen Ganir <chen.ganir@ti.com>
Signed-off-by: default avatarGustavo F. Padovan <padovan@profusion.mobi>
parent 2d20a26a
...@@ -124,6 +124,13 @@ static long st_receive(void *priv_data, struct sk_buff *skb) ...@@ -124,6 +124,13 @@ static long st_receive(void *priv_data, struct sk_buff *skb)
/* ------- Interfaces to HCI layer ------ */ /* ------- Interfaces to HCI layer ------ */
/* protocol structure registered with shared transport */ /* protocol structure registered with shared transport */
static struct st_proto_s ti_st_proto[MAX_BT_CHNL_IDS] = { static struct st_proto_s ti_st_proto[MAX_BT_CHNL_IDS] = {
{
.chnl_id = HCI_EVENT_PKT, /* HCI Events */
.hdr_len = sizeof(struct hci_event_hdr),
.offset_len_in_hdr = offsetof(struct hci_event_hdr, plen),
.len_size = 1, /* sizeof(plen) in struct hci_event_hdr */
.reserve = 8,
},
{ {
.chnl_id = HCI_ACLDATA_PKT, /* ACL */ .chnl_id = HCI_ACLDATA_PKT, /* ACL */
.hdr_len = sizeof(struct hci_acl_hdr), .hdr_len = sizeof(struct hci_acl_hdr),
...@@ -138,13 +145,6 @@ static struct st_proto_s ti_st_proto[MAX_BT_CHNL_IDS] = { ...@@ -138,13 +145,6 @@ static struct st_proto_s ti_st_proto[MAX_BT_CHNL_IDS] = {
.len_size = 1, /* sizeof(dlen) in struct hci_sco_hdr */ .len_size = 1, /* sizeof(dlen) in struct hci_sco_hdr */
.reserve = 8, .reserve = 8,
}, },
{
.chnl_id = HCI_EVENT_PKT, /* HCI Events */
.hdr_len = sizeof(struct hci_event_hdr),
.offset_len_in_hdr = offsetof(struct hci_event_hdr, plen),
.len_size = 1, /* sizeof(plen) in struct hci_event_hdr */
.reserve = 8,
},
}; };
/* Called from HCI core to initialize the device */ /* Called from HCI core to initialize the device */
...@@ -240,7 +240,7 @@ static int ti_st_close(struct hci_dev *hdev) ...@@ -240,7 +240,7 @@ static int ti_st_close(struct hci_dev *hdev)
if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
return 0; return 0;
for (i = 0; i < MAX_BT_CHNL_IDS; i++) { for (i = MAX_BT_CHNL_IDS-1; i >= 0; i--) {
err = st_unregister(&ti_st_proto[i]); err = st_unregister(&ti_st_proto[i]);
if (err) if (err)
BT_ERR("st_unregister(%d) failed with error %d", BT_ERR("st_unregister(%d) failed with error %d",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment