Return-Path: From: Florian Grandel To: linux-bluetooth@vger.kernel.org Subject: [PATCH v6 05/16] Bluetooth: mgmt: multi adv for get_adv_instance_flags() Date: Tue, 26 May 2015 02:34:12 +0200 Message-Id: <1432600463-7758-6-git-send-email-fgrandel@gmail.com> In-Reply-To: <1432600463-7758-1-git-send-email-fgrandel@gmail.com> References: <1432600463-7758-1-git-send-email-fgrandel@gmail.com> In-Reply-To: <1432507154-22925-1-git-send-email-fgrandel@gmail.com> References: <1432507154-22925-1-git-send-email-fgrandel@gmail.com> Sender: linux-bluetooth-owner@vger.kernel.org List-ID: The get_adv_instance_flags() would not work with instance identifiers other than 0x01. This is being fixed so that arbitrary instance identifiers can be dealt with while still correctly dealing with the special case of the 0x00 identifier. Signed-off-by: Florian Grandel --- net/bluetooth/mgmt.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index c28bb2d..5a531fd5 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -964,12 +964,17 @@ static bool get_connectable(struct hci_dev *hdev) static u32 get_adv_instance_flags(struct hci_dev *hdev, u8 instance) { u32 flags; + struct adv_info *adv_instance; - if (instance > 0x01) - return 0; + if (instance != 0x00) { + adv_instance = hci_find_adv_instance(hdev, instance); - if (instance == 0x01) - return hdev->adv_instance.flags; + /* Return 0 when we got an invalid instance identifier. */ + if (!adv_instance) + return 0; + + return adv_instance->flags; + } /* Instance 0 always manages the "Tx Power" and "Flags" fields */ flags = MGMT_ADV_FLAG_TX_POWER | MGMT_ADV_FLAG_MANAGED_FLAGS; -- 1.9.1