Skip to content

Commit a834a0b

Browse files
pvVudentz
authored andcommitted
Bluetooth: hci_sync: call destroy in hci_cmd_sync_run if immediate
hci_cmd_sync_run() may run the work immediately if called from existing sync work (otherwise it queues a new sync work). In this case it fails to call the destroy() function. On immediate run, make it behave same way as if item was queued successfully: call destroy, and return 0. The only callsite is hci_abort_conn() via hci_cmd_sync_run_once(), and this changes its return value. However, its return value is not used except as the return value for hci_disconnect(), and nothing uses the return value of hci_disconnect(). Hence there should be no behavior change anywhere. Fixes: c898f6d ("Bluetooth: hci_sync: Introduce hci_cmd_sync_run/hci_cmd_sync_run_once") Signed-off-by: Pauli Virtanen <pav@iki.fi> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
1 parent 48b3cd6 commit a834a0b

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

net/bluetooth/hci_sync.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -801,8 +801,15 @@ int hci_cmd_sync_run(struct hci_dev *hdev, hci_cmd_sync_work_func_t func,
801801
return -ENETDOWN;
802802

803803
/* If on cmd_sync_work then run immediately otherwise queue */
804-
if (current_work() == &hdev->cmd_sync_work)
805-
return func(hdev, data);
804+
if (current_work() == &hdev->cmd_sync_work) {
805+
int err;
806+
807+
err = func(hdev, data);
808+
if (destroy)
809+
destroy(hdev, data, err);
810+
811+
return 0;
812+
}
806813

807814
return hci_cmd_sync_submit(hdev, func, data, destroy);
808815
}

0 commit comments

Comments
 (0)