]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
Bluetooth: mgmt: Fix refresh cached connection info
authorZhengping Jiang <jiangzp@google.com>
Mon, 13 Jun 2022 21:43:27 +0000 (14:43 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:41:11 +0000 (14:41 +0200)
[ Upstream commit d7b2fdfb53ea09382941c0a4950dc9b00d51d1c7 ]

Set the connection data before calling get_conn_info_sync, so it can be
verified the connection is still connected, before refreshing cached
values.

Fixes: 47db6b42991e6 ("Bluetooth: hci_sync: Convert MGMT_OP_GET_CONN_INFO")
Signed-off-by: Zhengping Jiang <jiangzp@google.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/bluetooth/mgmt.c

index ae758ab1b558d3c0975517969aa1491eabb00fa4..12c1ecdba3f3af25d322c421807bac224043802f 100644 (file)
@@ -6821,11 +6821,14 @@ static int get_conn_info(struct sock *sk, struct hci_dev *hdev, void *data,
 
                cmd = mgmt_pending_new(sk, MGMT_OP_GET_CONN_INFO, hdev, data,
                                       len);
-               if (!cmd)
+               if (!cmd) {
                        err = -ENOMEM;
-               else
+               } else {
+                       hci_conn_hold(conn);
+                       cmd->user_data = hci_conn_get(conn);
                        err = hci_cmd_sync_queue(hdev, get_conn_info_sync,
                                                 cmd, get_conn_info_complete);
+               }
 
                if (err < 0) {
                        mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_CONN_INFO,
@@ -6837,9 +6840,6 @@ static int get_conn_info(struct sock *sk, struct hci_dev *hdev, void *data,
                        goto unlock;
                }
 
-               hci_conn_hold(conn);
-               cmd->user_data = hci_conn_get(conn);
-
                conn->conn_info_timestamp = jiffies;
        } else {
                /* Cache is valid, just reply with values cached in hci_conn */