Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4346931imw; Thu, 7 Jul 2022 17:32:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s41KMf5MggKfI8EaXqTjFUGn9uDQYZ1GrHOqTlkP8ZMEDbLM0AV7mGXJoabWidVqYWe737 X-Received: by 2002:a17:906:37c6:b0:70c:f9f:f0c5 with SMTP id o6-20020a17090637c600b0070c0f9ff0c5mr771368ejc.743.1657240331645; Thu, 07 Jul 2022 17:32:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657240331; cv=none; d=google.com; s=arc-20160816; b=yug4PSCSXHg3b55445j9FssOwR5BpHNYthzVg9Yy2QRo4uS/rWPJirj6ooty8BYJvI 41YFeRrBivpgH+cM/0QWHlxLlNZ7xZUnPl7+mPvjd7920uiGJeKrt1oIb4h9YYpEW3OF jx0S2GJ/OGgbuRppVr/HwqMALM50RDUkbZGvcPxjCvb0BZfrcjyrc/go/LaJTQGPLCoJ qye4HiYMsGIHzII5KN7z0UshpgS+4+MLBH0GuZpA1YvF4jsy9Nv+uW8YwAsp+Uh6CWom 9ECJ9qoMzqSedcvN+T36UiDj25uP9CZ/RKZ5jMW30ZZB3n3WT4HWxlfFdYDu8ZOw3fxm On4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from:dkim-signature; bh=by5m2iFUIfHoOpzC7kFFnoqzfj2UJTvg+y89CRvwSuU=; b=PWRGsuCT1wtEJt/WNEzFEYtSME0x1pLPON0PmZ6r0TxJZbZtwGg6D2yQKobC6E81ku K8AtdVB9dzSOwK1CK+MWtvsZqdJ0aX5NjxXqXinsBX07g4PE3xxqxtGJ8HgvCcKWpuin Gk1J0ltDlcDqzxvSUFwTyys1D7LHv30G/WdKUvpKl6P+SMimG8Rr+oTiFIOHM2GYo+kM zD6/PQHNXSv78Dd7Su2/drbMCK1zBM+M3eKFM24bL8ad1nFbpOxLR1AcW1m35Z5IKSMa JQXTyZ0WV2bUg9BE2s5oRpe2ErUddUAJI+eMuYt4ZQQdyqVNaYd9MFfLjNI+Lg4b9kn4 WXoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=i0h5IsnT; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id di22-20020a170906731600b006df76385e6csi39564637ejc.780.2022.07.07.17.30.45; Thu, 07 Jul 2022 17:32:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=i0h5IsnT; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237002AbiGHA2F (ORCPT + 99 others); Thu, 7 Jul 2022 20:28:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236799AbiGHA2A (ORCPT ); Thu, 7 Jul 2022 20:28:00 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6278970E48 for ; Thu, 7 Jul 2022 17:27:59 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id q5-20020a17090a304500b001efcc885cc4so362763pjl.4 for ; Thu, 07 Jul 2022 17:27:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=by5m2iFUIfHoOpzC7kFFnoqzfj2UJTvg+y89CRvwSuU=; b=i0h5IsnTy4UvyeH3Bmsps0ECRr4AadkL12Yi8n/8ms1Jyb/CCH3IA7h9XtJR3Z71Vq T7YUDhPhzQGH0etafZxWJvEik83rWZwHF7Gr7thJCnHPqlnTUZU/E4Y9uhnKc5tawM6j VB9+aba+mvKSkvYvcpGtZiCsWGDXirXIXoXnAa4VOajbMPDHcjI9Uf/JpmesVEijJtpF is150IeQSaltSssbGHxbwfkFM2GNVZ/RiLfMNDgRSuEF1NZwFxt3WQgB65+pLI/rbdl9 rlONbUSBeU/aYTWn3LEhq4kvAwrQQR9miXAKQdUGL7wrIdb+d1v/4UVygEk+WNsqD/AY T6nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=by5m2iFUIfHoOpzC7kFFnoqzfj2UJTvg+y89CRvwSuU=; b=LggatAHFl7kJkXCJgGxIhbRFqoVjLBX1MDwATwl3HwU7sYqX6qf0YYWCQYUyhl3eyR XaxLWnkX/3sYoKJ4Hi109F5ShS2dkD/tEFHYebd39orgOUNvEupJ+oKN7LpMqW6qGr1c d6B5FcrpuwBYQLLBj9Fuho4iE4XuXWC23OEUs9MO3TJPBa1Vgle3DWqo8jv2wGyHXNX3 zjT2n/dTCOchI408bF5/8bgLngwJtO8NNl5jmUNKDZkTxvn31ieXn/2R1vYhDzHi/i4s ExDJH05dHriaPs2TEGuUuXPrZHWffAnyzkkJQcnQRYhe3yb3NQi2MmS10saGC96ByJ5Z EnuQ== X-Gm-Message-State: AJIora9cfkSCsYUPu5QWuOEgWxAUbTSlzBMUizZUOvUbE2i5xZuRXHZC xLT7EMJDJ/9wnp8DfsHFdzbFw0aNme8= X-Received: by 2002:a17:902:c102:b0:16b:e03a:40ff with SMTP id 2-20020a170902c10200b0016be03a40ffmr840488pli.29.1657240078341; Thu, 07 Jul 2022 17:27:58 -0700 (PDT) Received: from lvondent-mobl4.. (c-71-56-157-77.hsd1.or.comcast.net. [71.56.157.77]) by smtp.gmail.com with ESMTPSA id f9-20020a170902684900b00168c52319c3sm28473071pln.149.2022.07.07.17.27.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 17:27:57 -0700 (PDT) From: Luiz Augusto von Dentz 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 Message-Id: <20220708002751.2308369-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Luiz Augusto von Dentz 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