Bluetooth: MGMT: Fix pending state of instances added without HCI traffic

When Add Advertising completes without HCI communication, e.g. when the
device is not powered or the instance is overridden by Global
Advertising, the instance is left marked as pending, so a subsequent
failure in add_adv_complete would remove it despite it having been
successfully added.

Fix this by clearing the pending state before completing the command.

Fixes: fffd38bca5 ("Bluetooth: mgmt/hci_core: multi-adv for add_advertising*()")
Assisted-by: OpenCode:claude-opus-5.5
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2026-10-05 13:39:25 -04:00
parent 1bfecdbd03
commit 5548fb51aa

View File

@ -9173,6 +9173,12 @@ static int add_advertising(struct sock *sk, struct hci_dev *hdev,
if (!hdev_is_powered(hdev) ||
adv_overridden_by_global(hdev, adv) ||
!schedule_instance) {
/* Instance has been accepted so it shall no longer be
* considered pending, otherwise a later failure in
* add_adv_complete would remove it.
*/
adv->pending = false;
rp.instance = cp->instance;
err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_ADD_ADVERTISING,
MGMT_STATUS_SUCCESS, &rp, sizeof(rp));