linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ] btdev: Fix not checking if a CIG has any active CIS
Date: Thu,  7 Jul 2022 17:27:51 -0700	[thread overview]
Message-ID: <20220708002751.2308369-1-luiz.dentz@gmail.com> (raw)

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

Bluetooth Core specification says the CIG must be in configurable state
in order to accept the SetCIGParameters:

BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E page 2553:

 'If the Host issues this command when the CIG is not in the
  configurable state, the Controller shall return the error
  code Command Disallowed (0x0C).'
---
 emulator/btdev.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/emulator/btdev.c b/emulator/btdev.c
index 641e308b3..3fdfb64a9 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -5831,8 +5831,25 @@ static int cmd_set_cig_params(struct btdev *dev, const void *data,
 	rsp.params.cig_id = cmd->cig_id;
 
 	for (i = 0; i < cmd->num_cis; i++) {
+		struct btdev_conn *iso;
+
 		rsp.params.num_handles++;
 		rsp.handle[i] = cpu_to_le16(ISO_HANDLE + i);
+
+		/* BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E
+		 * page 2553
+		 *
+		 * If the Host issues this command when the CIG is not in the
+		 * configurable state, the Controller shall return the error
+		 * code Command Disallowed (0x0C).
+		 */
+		iso = queue_find(dev->conns, match_handle,
+				UINT_TO_PTR(cpu_to_le16(rsp.handle[i])));
+		if (iso) {
+			rsp.params.status = BT_HCI_ERR_INVALID_PARAMETERS;
+			i = 0;
+			goto done;
+		}
 	}
 
 done:
-- 
2.35.3


             reply	other threads:[~2022-07-08  0:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-08  0:27 Luiz Augusto von Dentz [this message]
2022-07-08  3:01 ` [BlueZ] btdev: Fix not checking if a CIG has any active CIS bluez.test.bot
2022-07-11 16:40 ` [PATCH BlueZ] " patchwork-bot+bluetooth

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=20220708002751.2308369-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;
as well as URLs for NNTP newsgroup(s).