When calling hci_conn_params_clear function, it should update the
background scanning properly and not require a separate call to
update it.
For the case when the function is used during unregister of a
controller, an extra safe guard is but in place.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
        } else if (memcmp(buf, "clr", 3) == 0) {
                hci_dev_lock(hdev);
                hci_conn_params_clear(hdev);
-               hci_update_background_scan(hdev);
                hci_dev_unlock(hdev);
        } else {
                err = -EINVAL;
        }
 
        BT_DBG("All LE pending connections cleared");
+
+       hci_update_background_scan(hdev);
 }
 
 /* This function requires the caller holds hdev->lock */
        struct hci_conn *conn;
        int err;
 
+       if (test_bit(HCI_UNREGISTER, &hdev->dev_flags))
+               return;
+
        hci_req_init(&req, hdev);
 
        if (list_empty(&hdev->pend_le_conns)) {