diff options
-rw-r--r-- | net/bluetooth/mgmt.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index fc807dcc2533..04efc56d1641 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c | |||
@@ -1014,8 +1014,18 @@ static u8 get_cur_adv_instance_scan_rsp_len(struct hci_dev *hdev) | |||
1014 | 1014 | ||
1015 | static u8 create_instance_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr) | 1015 | static u8 create_instance_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr) |
1016 | { | 1016 | { |
1017 | struct adv_info *adv_instance = NULL; | ||
1017 | u8 ad_len = 0, flags = 0; | 1018 | u8 ad_len = 0, flags = 0; |
1018 | u32 instance_flags = get_adv_instance_flags(hdev, instance); | 1019 | u32 instance_flags; |
1020 | |||
1021 | /* Return 0 when the current instance identifier is invalid. */ | ||
1022 | if (instance) { | ||
1023 | adv_instance = hci_find_adv_instance(hdev, instance); | ||
1024 | if (!adv_instance) | ||
1025 | return 0; | ||
1026 | } | ||
1027 | |||
1028 | instance_flags = get_adv_instance_flags(hdev, instance); | ||
1019 | 1029 | ||
1020 | /* The Add Advertising command allows userspace to set both the general | 1030 | /* The Add Advertising command allows userspace to set both the general |
1021 | * and limited discoverable flags. | 1031 | * and limited discoverable flags. |
@@ -1049,12 +1059,11 @@ static u8 create_instance_adv_data(struct hci_dev *hdev, u8 instance, u8 *ptr) | |||
1049 | } | 1059 | } |
1050 | } | 1060 | } |
1051 | 1061 | ||
1052 | if (instance) { | 1062 | if (adv_instance) { |
1053 | memcpy(ptr, hdev->adv_instance.adv_data, | 1063 | memcpy(ptr, adv_instance->adv_data, |
1054 | hdev->adv_instance.adv_data_len); | 1064 | adv_instance->adv_data_len); |
1055 | 1065 | ad_len += adv_instance->adv_data_len; | |
1056 | ad_len += hdev->adv_instance.adv_data_len; | 1066 | ptr += adv_instance->adv_data_len; |
1057 | ptr += hdev->adv_instance.adv_data_len; | ||
1058 | } | 1067 | } |
1059 | 1068 | ||
1060 | /* Provide Tx Power only if we can provide a valid value for it */ | 1069 | /* Provide Tx Power only if we can provide a valid value for it */ |