From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>,
Sasha Levin <sashal@kernel.org>,
marcel@holtmann.org, johan.hedberg@gmail.com,
luiz.dentz@gmail.com, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com,
linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.18 80/93] Bluetooth: mgmt: Fix using hci_conn_abort
Date: Thu, 11 Aug 2022 11:42:14 -0400 [thread overview]
Message-ID: <20220811154237.1531313-80-sashal@kernel.org> (raw)
In-Reply-To: <20220811154237.1531313-1-sashal@kernel.org>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
[ Upstream commit 1f7435c8f6558a94f75b408a74140bdcbd0f6dd1 ]
This fixes using hci_conn_abort instead of using hci_conn_abort_sync.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
include/net/bluetooth/hci_sync.h | 2 ++
net/bluetooth/hci_sync.c | 3 +--
net/bluetooth/mgmt.c | 38 +++++++++++++++++++++++++++++---
3 files changed, 38 insertions(+), 5 deletions(-)
diff --git a/include/net/bluetooth/hci_sync.h b/include/net/bluetooth/hci_sync.h
index 2492e3b46a8f..544e949b5dbf 100644
--- a/include/net/bluetooth/hci_sync.h
+++ b/include/net/bluetooth/hci_sync.h
@@ -105,4 +105,6 @@ int hci_resume_sync(struct hci_dev *hdev);
struct hci_conn;
+int hci_abort_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, u8 reason);
+
int hci_le_create_conn_sync(struct hci_dev *hdev, struct hci_conn *conn);
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 5c352db71819..fc6b91669327 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -4404,8 +4404,7 @@ static int hci_reject_conn_sync(struct hci_dev *hdev, struct hci_conn *conn,
sizeof(cp), &cp, HCI_CMD_TIMEOUT);
}
-static int hci_abort_conn_sync(struct hci_dev *hdev, struct hci_conn *conn,
- u8 reason)
+int hci_abort_conn_sync(struct hci_dev *hdev, struct hci_conn *conn, u8 reason)
{
int err;
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index ae758ab1b558..5b5bee52e835 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -2528,6 +2528,37 @@ static int device_unpaired(struct hci_dev *hdev, bdaddr_t *bdaddr,
skip_sk);
}
+static void unpair_device_complete(struct hci_dev *hdev, void *data, int err)
+{
+ struct mgmt_pending_cmd *cmd = data;
+ struct mgmt_cp_unpair_device *cp = cmd->param;
+
+ if (!err)
+ device_unpaired(hdev, &cp->addr.bdaddr, cp->addr.type, cmd->sk);
+
+ cmd->cmd_complete(cmd, err);
+ mgmt_pending_free(cmd);
+}
+
+static int unpair_device_sync(struct hci_dev *hdev, void *data)
+{
+ struct mgmt_pending_cmd *cmd = data;
+ struct mgmt_cp_unpair_device *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 0;
+
+ return hci_abort_conn_sync(hdev, conn, HCI_ERROR_REMOTE_USER_TERM);
+}
+
static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data,
u16 len)
{
@@ -2638,7 +2669,7 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data,
goto unlock;
}
- cmd = mgmt_pending_add(sk, MGMT_OP_UNPAIR_DEVICE, hdev, cp,
+ cmd = mgmt_pending_new(sk, MGMT_OP_UNPAIR_DEVICE, hdev, cp,
sizeof(*cp));
if (!cmd) {
err = -ENOMEM;
@@ -2647,9 +2678,10 @@ static int unpair_device(struct sock *sk, struct hci_dev *hdev, void *data,
cmd->cmd_complete = addr_cmd_complete;
- err = hci_abort_conn(conn, HCI_ERROR_REMOTE_USER_TERM);
+ err = hci_cmd_sync_queue(hdev, unpair_device_sync, cmd,
+ unpair_device_complete);
if (err < 0)
- mgmt_pending_remove(cmd);
+ mgmt_pending_free(cmd);
unlock:
hci_dev_unlock(hdev);
--
2.35.1
next prev parent reply other threads:[~2022-08-11 16:10 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220811154237.1531313-1-sashal@kernel.org>
2022-08-11 15:40 ` [PATCH AUTOSEL 5.18 03/93] ath10k: htt_tx: do not interpret Eth frames as WiFi Sasha Levin
2022-08-11 15:40 ` [PATCH AUTOSEL 5.18 04/93] ath10k: fix misreported tx bandwidth for 160Mhz Sasha Levin
2022-08-11 15:41 ` [PATCH AUTOSEL 5.18 09/93] ath10k: fix regdomain info of iw reg set/get Sasha Levin
2022-08-11 15:41 ` [PATCH AUTOSEL 5.18 10/93] bpf, sockmap: Fix sk->sk_forward_alloc warn_on in sk_stream_kill_queues Sasha Levin
2022-08-11 15:41 ` [PATCH AUTOSEL 5.18 15/93] iavf: Add waiting for response from PF in set mac Sasha Levin
2022-08-11 15:41 ` [PATCH AUTOSEL 5.18 22/93] net/mlx5: Add HW definitions of vport debug counters Sasha Levin
2022-08-11 15:41 ` [PATCH AUTOSEL 5.18 25/93] net: phy: marvell-88x2222: set proper phydev->port Sasha Levin
2022-08-11 15:41 ` [PATCH AUTOSEL 5.18 26/93] selftests: mlxsw: resource_scale: Allow skipping a test Sasha Levin
2022-08-11 15:41 ` [PATCH AUTOSEL 5.18 27/93] net: make xpcs_do_config to accept advertising for pcs-xpcs and sja1105 Sasha Levin
2022-08-11 15:41 ` [PATCH AUTOSEL 5.18 28/93] net: stmmac: make mdio register skips PHY scanning for fixed-link Sasha Levin
2022-08-11 15:41 ` [PATCH AUTOSEL 5.18 29/93] net: dsa: ar9331: fix potential dead lock on mdio access Sasha Levin
2022-08-11 15:41 ` [PATCH AUTOSEL 5.18 40/93] mlxsw: cmd: Increase 'config_profile.flood_mode' length Sasha Levin
2022-08-11 15:41 ` [PATCH AUTOSEL 5.18 46/93] ipv6/addrconf: fix timing bug in tempaddr regen Sasha Levin
2022-08-11 15:41 ` [PATCH AUTOSEL 5.18 50/93] octeontx2-af: fix operand size in bitwise operation Sasha Levin
2022-08-11 15:41 ` [PATCH AUTOSEL 5.18 59/93] octeontx2-af: Don't reset previous pfc config Sasha Levin
2022-08-11 15:41 ` [PATCH AUTOSEL 5.18 61/93] bpf: Make non-preallocated allocation low priority Sasha Levin
2022-08-11 15:42 ` [PATCH AUTOSEL 5.18 68/93] net: devlink: avoid false DEADLOCK warning reported by lockdep Sasha Levin
2022-08-11 15:42 ` [PATCH AUTOSEL 5.18 69/93] bpf: Don't redirect packets with invalid pkt_len Sasha Levin
2022-08-11 15:42 ` [PATCH AUTOSEL 5.18 71/93] can: sja1000: Add Quirk for RZ/N1 SJA1000 CAN controller Sasha Levin
2022-08-11 15:42 ` [PATCH AUTOSEL 5.18 74/93] Bluetooth: use memset avoid memory leaks Sasha Levin
2022-08-11 15:42 ` [PATCH AUTOSEL 5.18 75/93] Bluetooth: Collect kcov coverage from hci_rx_work Sasha Levin
2022-08-11 15:42 ` [PATCH AUTOSEL 5.18 77/93] Bluetooth: hci_sync: Check LMP feature bit instead of quirk Sasha Levin
2022-08-11 15:42 ` Sasha Levin [this message]
2022-08-11 15:42 ` [PATCH AUTOSEL 5.18 81/93] bpf/selftests: Fix couldn't retrieve pinned program in xdp veth test Sasha Levin
2022-08-11 15:42 ` [PATCH AUTOSEL 5.18 85/93] net: ethernet: stmicro: stmmac: first disable all queues and disconnect in release Sasha Levin
2022-08-11 15:42 ` [PATCH AUTOSEL 5.18 86/93] wifi: rtl8xxxu: Fix the error handling of the probe function Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220811154237.1531313-80-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=johan.hedberg@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=luiz.von.dentz@intel.com \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).