Bluetooth: hci_sync: Fix overwriting request callback
Subsystems (2)
Luiz Augusto von Dentz
maintainerPATCH 1/1 Bluetooth: hci_sync: Fix overwriting request callback
From: Luiz Augusto von Dentz <[email protected]>
In a few cases the stack may generate commands as responses to events which would happen to overwrite the sent_cmd, so this attempts to store the request in req_skb so even if sent_cmd is replaced with a new command the pending request will remain in stored in req_skb.
Signed-off-by Luiz Augusto von Dentz <[email protected]>
--- net/bluetooth/hci_conn.c | 2 +- net/bluetooth/hci_core.c | 46 +++++++++++++++++++++++++++------------ net/bluetooth/hci_event.c | 18 +++++++-------- net/bluetooth/hci_sync.c | 12 ++++++++++ 4 files changed, 54 insertions(+), 24 deletions(-)
net/bluetooth/hci_conn.c +1 -1
@@ -2893,7 +2893,7 @@ int hci_abort_conn(struct hci_conn *conn, u8 reason)* connection can be in BT_CONNECT at time. */ if (conn->state ==BT_CONNECT && hdev->req_status ==HCI_REQ_PEND ) { -switch (hci_skb_event (hdev->sent_cmd)) { +switch (hci_skb_event (hdev->req_skb)) {case HCI_EV_CONN_COMPLETE :case HCI_EV_LE_CONN_COMPLETE :case HCI_EV_LE_ENHANCED_CONN_COMPLETE :
net/bluetooth/hci_core.c +32 -14
92 lines not on this page · raw message
net/bluetooth/hci_event.c +9 -9
@@ -4368,7 +4368,7 @@ static void hci_cmd_status_evt(struct hci_dev *hdev, void *data,* (since for this kind of commands there will not be a command * complete event). */ -if (ev->status || (hdev->sent_cmd && !hci_skb_event (hdev->sent_cmd))) { +if (ev->status || (hdev->req_skb && !hci_skb_event (hdev->req_skb))) {hci_req_cmd_complete (hdev, *opcode, ev->status, req_complete, req_complete_skb);if (hci_dev_test_flag (hdev,HCI_CMD_PENDING )) {
@@ -7170,10 +7170,10 @@ static void hci_le_meta_evt(struct hci_dev *hdev, void *data,bt_dev_dbg (hdev,"subevent 0x%2.2x" , ev->subevent);/* Only match event if command OGF is for LE */ -if (hdev->sent_cmd && -hci_opcode_ogf (hci_skb_opcode (hdev->sent_cmd)) ==0x08 && -hci_skb_event (hdev->sent_cmd) == ev->subevent) { - *opcode =hci_skb_opcode (hdev->sent_cmd); +if (hdev->req_skb && +hci_opcode_ogf (hci_skb_opcode (hdev->req_skb)) ==0x08 && +hci_skb_event (hdev->req_skb) == ev->subevent) { + *opcode =hci_skb_opcode (hdev->req_skb);hci_req_cmd_complete (hdev, *opcode,0x00 , req_complete, req_complete_skb); }
@@ -7541,10 +7541,10 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) }/* Only match event if command OGF is not for LE */ -if (hdev->sent_cmd && -hci_opcode_ogf (hci_skb_opcode (hdev->sent_cmd)) !=0x08 && -hci_skb_event (hdev->sent_cmd) == event) { -hci_req_cmd_complete (hdev,hci_skb_opcode (hdev->sent_cmd), +if (hdev->req_skb && +hci_opcode_ogf (hci_skb_opcode (hdev->req_skb)) !=0x08 && +hci_skb_event (hdev->req_skb) == event) { +hci_req_cmd_complete (hdev,hci_skb_opcode (hdev->req_skb), status, &req_complete, &req_complete_skb); req_evt = event; }
net/bluetooth/hci_sync.c +12 -0
@@ -39,6 +39,7 @@ static void hci_cmd_sync_complete(struct hci_dev *hdev, u8 result, u16 opcode,if (sk)sock_put (sk); +kfree_skb (hdev->req_skb); hdev->req_skb =skb_get (skb); }
@@ -4952,6 +4953,11 @@ int hci_dev_open_sync(struct hci_dev *hdev) hdev->sent_cmd =NULL ; } +if (hdev->req_skb) { +kfree_skb (hdev->req_skb); + hdev->req_skb =NULL ; + } +clear_bit (HCI_RUNNING , &hdev->flags);hci_sock_dev_event (hdev,HCI_DEV_CLOSE );
@@ -5112,6 +5118,12 @@ int hci_dev_close_sync(struct hci_dev *hdev) hdev->sent_cmd =NULL ; } +/* Drop last request */ +if (hdev->req_skb) { +kfree_skb (hdev->req_skb); + hdev->req_skb =NULL ; + } +clear_bit (HCI_RUNNING , &hdev->flags);hci_sock_dev_event (hdev,HCI_DEV_CLOSE );
Signature · 1 line
2.43.0