public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH V2] shared/mgmt: Fix not processing request queue
Date: Fri,  4 Jun 2021 17:02:00 -0700	[thread overview]
Message-ID: <20210605000200.1938853-1-luiz.dentz@gmail.com> (raw)

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

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


             reply	other threads:[~2021-06-05  0:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-05  0:02 Luiz Augusto von Dentz [this message]
2021-06-05  0:40 ` [V2] shared/mgmt: Fix not processing request queue bluez.test.bot
2021-06-05  0:52   ` Luiz Augusto von Dentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210605000200.1938853-1-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox