From patchwork Mon Aug 26 20:25:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13778385 Received: from mail-vs1-f51.google.com (mail-vs1-f51.google.com [209.85.217.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D47A194AEF for ; Mon, 26 Aug 2024 20:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724703924; cv=none; b=ECdD/5rYjN5k3StLvtoTap4V2Gv4JHuyjEYhlJ1CtvtDFMlsUtJuUD/c8t2QGkRbcB8l23+Urw0weMGZQs3rPsUH+KouYe53z0MqsjXHrsblHbPMItOoagefXJ0r/tXBPyyxgxMTlTsNJHThJQwvEnv38SZLXCBI8ymd0O2jhk8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724703924; c=relaxed/simple; bh=i3bc9JwCIAY/CzUsnC+hGW60iuX8efZwwzQrv5oLSOE=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=AfWwjVnHzA0Mrb/6ZZoER66H2LyBx5Snxqffvw2JPNgXVli+pBu4FIJ+dzWhyRBUYESObSzX0wRdmLjmigCBzouskI3tBynwgoS/O0P3JyDRt1dxvL+JX+dubh57lGt5gQ6aN9/fGNyfZNVq/JkMHPWNss85CqgaZ11uMuwrD5c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=D/6AKcFb; arc=none smtp.client-ip=209.85.217.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D/6AKcFb" Received: by mail-vs1-f51.google.com with SMTP id ada2fe7eead31-498cf14a848so1571519137.3 for ; Mon, 26 Aug 2024 13:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724703921; x=1725308721; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=MIBJlvoJyQt5yhkogIg2C4Mf00EV4uxKnogdf+CUEbo=; b=D/6AKcFbc4Ia6znlZQXFhGQ2cwppl7rtJgTtgIAxUJYhHmJaZF1NonVEdNC+JH9Npy SaiSP9/zUB8lnw9PXO3GswvzvGFY7N0zO5pIUPhB1JFcdn5f1Z14LCOWWftDmSfKmhh1 xgGdLWsACQqSrcuCv2dZIS+pHLMgExZz2WxkeGkuFAcmHHL0mNAH9PKjjHg8kKBECrOX VVd3olHr45nmyQxRDiAuBgUL/APH8n8FQD3FfxSj3wQXm3/KghyK+fJzGh5HrllIy2Bw r7z3rDHyTMnUxcWlZowlWeXtu/USDhtINlZ3jWy7vkBIS4Nr68MOjoEH0JvjJVxihDQ+ 38KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724703921; x=1725308721; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MIBJlvoJyQt5yhkogIg2C4Mf00EV4uxKnogdf+CUEbo=; b=LaeHL8cGGtUr3N6FIkA6tnETt4rrUU4z2qJ3dcGjO6GdSt1PSD4CZ2d0rR9BV9n4Jc f12/PgYsXSQ090XSUrAwPE2LZBpbOfppqf+gGR+lcrax/Md+EIfFA1fGsGDOqtQaoayF 0Q8C2QMBYwxXgZ5OBic3OJs/XYcTgYAx+Hha+oiyUQNgaT+es6wsbShiCpVmbhxoRWYx sbA0dmP3TAMZ2PEEJ3nzGhhfpr60Er3VJ3oYvptzCrVSHdOLCS8n3E0W/tVu/Xtcui+s M+LGCqzBp/vEMWwz/E5UrSlmGvvjszraIsT7SFvHg2In/stew/dJEGe8wOPDb6PGO6lz /0Fg== X-Gm-Message-State: AOJu0YwKgVqTTuDXMK24fFwcLp97AxwEc8LV2V6dpBxv1llXF1ARpiSE 7TWVFjVdBvA2gz+4179ehHX72qRElERfkTiSaLYwImirj87PswM5EBDuPw== X-Google-Smtp-Source: AGHT+IGnyxkJ7HxllPwO2tQNKXQ4gVC5m84hVG1c8AZ2tybk2lWIWr+G00gRduq/4qo2NEMGYXQWgA== X-Received: by 2002:a05:6102:5125:b0:492:a6fb:23e5 with SMTP id ada2fe7eead31-498f4b13f69mr14280128137.3.1724703920538; Mon, 26 Aug 2024 13:25:20 -0700 (PDT) Received: from lvondent-mobl5.. (syn-107-146-107-067.res.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-844ce572f68sm1195475241.29.2024.08.26.13.25.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 13:25:19 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 1/2] Bluetooth: hci_sync: Introduce hci_cmd_sync_run/hci_cmd_sync_run_once Date: Mon, 26 Aug 2024 16:25:17 -0400 Message-ID: <20240826202518.524007-1-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.46.0 Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz This introduces hci_cmd_sync_run/hci_cmd_sync_run_once which acts like hci_cmd_sync_queue/hci_cmd_sync_queue_once but runs immediately when already on hdev->cmd_sync_work context. Signed-off-by: Luiz Augusto von Dentz --- include/net/bluetooth/hci_sync.h | 4 +++ net/bluetooth/hci_sync.c | 42 ++++++++++++++++++++++++++++++-- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/include/net/bluetooth/hci_sync.h b/include/net/bluetooth/hci_sync.h index 75e052909b5f..f3052cb252ef 100644 --- a/include/net/bluetooth/hci_sync.h +++ b/include/net/bluetooth/hci_sync.h @@ -73,6 +73,10 @@ int hci_cmd_sync_queue(struct hci_dev *hdev, hci_cmd_sync_work_func_t func, void *data, hci_cmd_sync_work_destroy_t destroy); int hci_cmd_sync_queue_once(struct hci_dev *hdev, hci_cmd_sync_work_func_t func, void *data, hci_cmd_sync_work_destroy_t destroy); +int hci_cmd_sync_run(struct hci_dev *hdev, hci_cmd_sync_work_func_t func, + void *data, hci_cmd_sync_work_destroy_t destroy); +int hci_cmd_sync_run_once(struct hci_dev *hdev, hci_cmd_sync_work_func_t func, + void *data, hci_cmd_sync_work_destroy_t destroy); struct hci_cmd_sync_work_entry * hci_cmd_sync_lookup_entry(struct hci_dev *hdev, hci_cmd_sync_work_func_t func, void *data, hci_cmd_sync_work_destroy_t destroy); diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c index e79cd40bd079..5533e6f561b3 100644 --- a/net/bluetooth/hci_sync.c +++ b/net/bluetooth/hci_sync.c @@ -112,7 +112,7 @@ static void hci_cmd_sync_add(struct hci_request *req, u16 opcode, u32 plen, skb_queue_tail(&req->cmd_q, skb); } -static int hci_cmd_sync_run(struct hci_request *req) +static int hci_req_sync_run(struct hci_request *req) { struct hci_dev *hdev = req->hdev; struct sk_buff *skb; @@ -169,7 +169,7 @@ struct sk_buff *__hci_cmd_sync_sk(struct hci_dev *hdev, u16 opcode, u32 plen, hdev->req_status = HCI_REQ_PEND; - err = hci_cmd_sync_run(&req); + err = hci_req_sync_run(&req); if (err < 0) return ERR_PTR(err); @@ -782,6 +782,44 @@ int hci_cmd_sync_queue_once(struct hci_dev *hdev, hci_cmd_sync_work_func_t func, } EXPORT_SYMBOL(hci_cmd_sync_queue_once); +/* Run HCI command: + * + * - hdev must be running + * - if on cmd_sync_work then run immediately otherwise queue + */ +int hci_cmd_sync_run(struct hci_dev *hdev, hci_cmd_sync_work_func_t func, + void *data, hci_cmd_sync_work_destroy_t destroy) +{ + /* Only queue command if hdev is running which means it had been opened + * and is either on init phase or is already up. + */ + if (!test_bit(HCI_RUNNING, &hdev->flags)) + return -ENETDOWN; + + /* If on cmd_sync_work then run immediately otherwise queue */ + if (current_work() == &hdev->cmd_sync_work) + return func(hdev, data); + + return hci_cmd_sync_submit(hdev, func, data, destroy); +} +EXPORT_SYMBOL(hci_cmd_sync_run); + +/* Run HCI command entry once: + * + * - Lookup if an entry already exist and only if it doesn't creates a new entry + * and run it. + * - if on cmd_sync_work then run immediately otherwise queue + */ +int hci_cmd_sync_run_once(struct hci_dev *hdev, hci_cmd_sync_work_func_t func, + void *data, hci_cmd_sync_work_destroy_t destroy) +{ + if (hci_cmd_sync_lookup_entry(hdev, func, data, destroy)) + return 0; + + return hci_cmd_sync_run(hdev, func, data, destroy); +} +EXPORT_SYMBOL(hci_cmd_sync_run_once); + /* Lookup HCI command entry: * * - Return first entry that matches by function callback or data or From patchwork Mon Aug 26 20:25:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luiz Augusto von Dentz X-Patchwork-Id: 13778386 Received: from mail-ua1-f52.google.com (mail-ua1-f52.google.com [209.85.222.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F940199EA6 for ; Mon, 26 Aug 2024 20:25:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724703925; cv=none; b=cgqwpI7anMseL/X+GbdFh0ej7ndSlhnPqee8XPcLqjkNKUkb3jxy7WrP+uT32o8LZ7mUp0+156n+jWcntF6Kr8bBTkVHACve/0Ix5suFQP8t6YqA/wAE64fG286BzU4M/lGdBb6Dfl0ggy5wHZW17OaBnlqc5sXxZr0XiimVKMg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724703925; c=relaxed/simple; bh=jSpyShSQBFJOPEmOIUo5Wn7gDssRx4wD9dnq8cBD4Rg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fkf5162Y+NpAnrJGTt4R18ekkJtRsSWjezF6nDkDfp4tChcBYA4YjqA2J5ZJCUXggZ7oGvj7o5FECIYMhqimAFVXGJFoLX0fRSBz06WlkJwhipRoMrhgjLp+BkYtbflsqpPaZ88aSAfT1cvnwp6zCQQql0pBShbkOE1gBkWgimw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=iIXWlXCA; arc=none smtp.client-ip=209.85.222.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iIXWlXCA" Received: by mail-ua1-f52.google.com with SMTP id a1e0cc1a2514c-8430557e436so1356887241.2 for ; Mon, 26 Aug 2024 13:25:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724703922; x=1725308722; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=D1iJS8WrD3YqpQ2TSihxoSRoS98guPNwg5uUmaBpykE=; b=iIXWlXCAwWGeOvjrVzJc8LcWxjT2SY4QOJOcOJtFVNeSWUrV+g81DdpZg3iCO092Qo eyYrLM/L0piHN9dM1uqzuSQt69jwVrf3SYPM73dhpjx4gX+0lL7dm2dCAHYxSzB4g0Zy dhx/SNBhDg8UpgY3GmmcSWLoJe08aBEEQN2nw6PKOh5gVj7zppHyGE60742jBKMgQLfX TwlYsoquJI54K3nRnNFBGSQxRfI9rbWwREopkhjRV9v8aNz6NFVY+Ij56sr6wWNF6wio lZEmyfPMKw4Mj/csFcGR8xXfj/Bmc5Ydz3Ag8VZVhlIlzKtlu3tWmb1R9iziUbwKBJP/ 9M+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724703922; x=1725308722; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=D1iJS8WrD3YqpQ2TSihxoSRoS98guPNwg5uUmaBpykE=; b=M+Wi7kASYU3W/2/ZS9yLO1fGqe18LyyypSdYfnD7REguB15i21FaEjj7rFgnPeuV7p AmJaCFXmG9WUdUAncHevwoTha5enPzwdTgqPXRSorrGOXXeIGtBTKjBWpnUs4Lnv7mC4 JNvBsXNJAUX2d+hmySgkFrvEAY6skniTJrlHfBoGGSfBQLygRdLrQ7V55aX6UTxLKO45 CMUxYXvQh25uFzbgnJYPuSX3QKchxIvlsZz7XRxzFSIB7AslgMqA3cOguswjZjSTPkGc 2KDbtx5KAA/sSDbHd3WhQ8ztjMyvtYFuTy1SC0Kx104FBXZJPgMRYonTcNDfELqQCKQx Hb7w== X-Gm-Message-State: AOJu0Yx3xpbqRJ01dh4j7AocC1tmKWRZGMpoRi0aGniqCPhvdP6B+BGU pdgI1+Y8JhZgHOuPM5qs8fy1RWp7PCzOp6ppuigQsHqF/iiQF5LxsUAXmg== X-Google-Smtp-Source: AGHT+IFz4FiuYNTeyGV45Zq26MXSSP7oK766ejJ3SEMbGPyA6GsVUrLz/txt+b2nfddpgzJxsqC5sw== X-Received: by 2002:a05:6102:cca:b0:495:6a25:d1ed with SMTP id ada2fe7eead31-49a3bcefe8emr1023926137.25.1724703922385; Mon, 26 Aug 2024 13:25:22 -0700 (PDT) Received: from lvondent-mobl5.. (syn-107-146-107-067.res.spectrum.com. [107.146.107.67]) by smtp.gmail.com with ESMTPSA id a1e0cc1a2514c-844ce572f68sm1195475241.29.2024.08.26.13.25.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Aug 2024 13:25:20 -0700 (PDT) From: Luiz Augusto von Dentz To: linux-bluetooth@vger.kernel.org Subject: [PATCH v2 2/2] Bluetooth: MGMT: Fix not generating command complete for MGMT_OP_DISCONNECT Date: Mon, 26 Aug 2024 16:25:18 -0400 Message-ID: <20240826202518.524007-2-luiz.dentz@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240826202518.524007-1-luiz.dentz@gmail.com> References: <20240826202518.524007-1-luiz.dentz@gmail.com> Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Luiz Augusto von Dentz MGMT_OP_DISCONNECT can be called while mgmt_device_connected has not been called yet, which will cause the connection procedure to be aborted, so mgmt_device_disconnected shall still respond with command complete to MGMT_OP_DISCONNECT and just not emit MGMT_EV_DEVICE_DISCONNECTED since MGMT_EV_DEVICE_CONNECTED was never sent. To fix this MGMT_OP_DISCONNECT is changed to work similarly to other command which do use hci_cmd_sync_queue and then use hci_conn_abort to disconnect and returns the result, in order for hci_conn_abort to be used from hci_cmd_sync context it now uses hci_cmd_sync_run_once. Link: https://github.com/bluez/bluez/issues/932 Fixes: 12d4a3b ("Bluetooth: Move check for MGMT_CONNECTED flag into mgmt.c") Signed-off-by: Luiz Augusto von Dentz --- net/bluetooth/hci_conn.c | 6 +++- net/bluetooth/mgmt.c | 72 +++++++++++++++++++++++----------------- 2 files changed, 47 insertions(+), 31 deletions(-) diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 8f0c9322eadb..6225f13177c3 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -2951,5 +2951,9 @@ int hci_abort_conn(struct hci_conn *conn, u8 reason) return 0; } - return hci_cmd_sync_queue_once(hdev, abort_conn_sync, conn, NULL); + /* Run immediately if on cmd_sync_work since it maybe called from + * as a result to MGMT_OP_DISCONNECT and MGMT_OP_UNPAIR which does + * already queue its callback on cmd_sync_work. + */ + return hci_cmd_sync_run_once(hdev, abort_conn_sync, conn, NULL); } diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 25979f4283a6..54dc9976abcf 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -2921,7 +2921,12 @@ static int unpair_device_sync(struct hci_dev *hdev, void *data) if (!conn) return 0; - return hci_abort_conn_sync(hdev, conn, HCI_ERROR_REMOTE_USER_TERM); + /* Disregard any possible error since the likes of hci_abort_conn_sync + * will cleanup the connection no matter the error. + */ + hci_abort_conn(conn, HCI_ERROR_REMOTE_USER_TERM); + + return 0; } static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, @@ -3053,13 +3058,44 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data, return err; } +static void disconnect_complete(struct hci_dev *hdev, void *data, int err) +{ + struct mgmt_pending_cmd *cmd = data; + + cmd->cmd_complete(cmd, mgmt_status(err)); + mgmt_pending_free(cmd); +} + +static int disconnect_sync(struct hci_dev *hdev, void *data) +{ + struct mgmt_pending_cmd *cmd = data; + struct mgmt_cp_disconnect *cp = cmd->param; + struct hci_conn *conn; + + if (cp->addr.type == BDADDR_BREDR) + conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, + &cp->addr.bdaddr); + else + conn = hci_conn_hash_lookup_le(hdev, &cp->addr.bdaddr, + le_addr_type(cp->addr.type)); + + if (!conn) + return -ENOTCONN; + + /* Disregard any possible error since the likes of hci_abort_conn_sync + * will cleanup the connection no matter the error. + */ + hci_abort_conn(conn, HCI_ERROR_REMOTE_USER_TERM); + + return 0; +} + static int disconnect(struct sock *sk, struct hci_dev *hdev, void *data, u16 len) { struct mgmt_cp_disconnect *cp = data; struct mgmt_rp_disconnect rp; struct mgmt_pending_cmd *cmd; - struct hci_conn *conn; int err; bt_dev_dbg(hdev, "sock %p", sk); @@ -3082,27 +3118,7 @@ static int disconnect(struct sock *sk, struct hci_dev *hdev, void *data, goto failed; } - if (pending_find(MGMT_OP_DISCONNECT, hdev)) { - err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_DISCONNECT, - MGMT_STATUS_BUSY, &rp, sizeof(rp)); - goto failed; - } - - if (cp->addr.type == BDADDR_BREDR) - conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, - &cp->addr.bdaddr); - else - conn = hci_conn_hash_lookup_le(hdev, &cp->addr.bdaddr, - le_addr_type(cp->addr.type)); - - if (!conn || conn->state == BT_OPEN || conn->state == BT_CLOSED) { - err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_DISCONNECT, - MGMT_STATUS_NOT_CONNECTED, &rp, - sizeof(rp)); - goto failed; - } - - cmd = mgmt_pending_add(sk, MGMT_OP_DISCONNECT, hdev, data, len); + cmd = mgmt_pending_new(sk, MGMT_OP_DISCONNECT, hdev, data, len); if (!cmd) { err = -ENOMEM; goto failed; @@ -3110,9 +3126,10 @@ static int disconnect(struct sock *sk, struct hci_dev *hdev, void *data, cmd->cmd_complete = generic_cmd_complete; - err = hci_disconnect(conn, HCI_ERROR_REMOTE_USER_TERM); + err = hci_cmd_sync_queue(hdev, disconnect_sync, cmd, + disconnect_complete); if (err < 0) - mgmt_pending_remove(cmd); + mgmt_pending_free(cmd); failed: hci_dev_unlock(hdev); @@ -9744,8 +9761,6 @@ void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, if (link_type != ACL_LINK && link_type != LE_LINK) return; - mgmt_pending_foreach(MGMT_OP_DISCONNECT, hdev, disconnect_rsp, &sk); - bacpy(&ev.addr.bdaddr, bdaddr); ev.addr.type = link_to_bdaddr(link_type, addr_type); ev.reason = reason; @@ -9758,9 +9773,6 @@ void mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, if (sk) sock_put(sk); - - mgmt_pending_foreach(MGMT_OP_UNPAIR_DEVICE, hdev, unpair_device_rsp, - hdev); } void mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr,