[PATCH V2] shared/mgmt: Fix not processing request queue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

If the kernel returns an invalid opcode like below the request won't
be processed making it unusable:

@ MGMT Command: Read Advertising Features (0x003d) plen 0
{0x0001} [hci0] 14:25:11.096370
@ MGMT Event: Command Status (0x0002) plen 3
{0x0001} [hci0] 14:25:11.096373
      Set Advertising (0x0029)
              Status: Not Supported (0x0c)

In order to fix this attempts to remove the first request pending on the
given index:

= bluetoothd: src/advertising.c:read_adv_features_callback() Failed to
read advertising features: Not Supported (0x0c)
---
 src/shared/mgmt.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c
index 3e9b9ee26..b869fa6ef 100644
--- a/src/shared/mgmt.c
+++ b/src/shared/mgmt.c
@@ -248,6 +248,17 @@ static void request_complete(struct mgmt *mgmt, uint8_t status,
 
 	request = queue_remove_if(mgmt->pending_list,
 					match_request_opcode_index, &match);
+	if (!request) {
+		util_debug(mgmt->debug_callback, mgmt->debug_data,
+				"Unable to find request for opcode 0x%04x",
+				opcode);
+
+		/* Attempt to remove with no opcode */
+		request = queue_remove_if(mgmt->pending_list,
+						match_request_index,
+						UINT_TO_PTR(index));
+	}
+
 	if (request) {
 		if (request->callback)
 			request->callback(status, length, param,
-- 
2.31.1




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux