From nobody Mon Sep 29 21:14:53 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F3ACCC25B0D for ; Tue, 16 Aug 2022 04:31:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229979AbiHPEbD (ORCPT ); Tue, 16 Aug 2022 00:31:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229673AbiHPEaa (ORCPT ); Tue, 16 Aug 2022 00:30:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AC2215CE28; Mon, 15 Aug 2022 13:18:21 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 913EDB81135; Mon, 15 Aug 2022 20:18:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE411C433C1; Mon, 15 Aug 2022 20:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660594693; bh=101aRdQRbjE4KjXETMaG5UNfHXPX9Z5bUYAjih/HHLg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b9z0UAYfy4Cb09EFv+3llONMhsBx4VSbZmupIR5AapEFGkpEsaglZprojaEeDKqoo 76Flb8q2ikI30wh7bYGk6RiuW3fEKHK8+8PUgn7DezAgkmO85QCR2vqGHUpYg+2D/P m4ItLlFMPAEHTBOkCLuNRdo1dZNsOv3GCiER404M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhengping Jiang , Luiz Augusto von Dentz , Sasha Levin Subject: [PATCH 5.19 0529/1157] Bluetooth: mgmt: Fix refresh cached connection info Date: Mon, 15 Aug 2022 19:58:05 +0200 Message-Id: <20220815180500.814458720@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Zhengping Jiang [ 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 Signed-off-by: Luiz Augusto von Dentz Signed-off-by: Sasha Levin --- net/bluetooth/mgmt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index 2f91a8c2b678..cbdf0e2bc5ae 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -6820,11 +6820,14 @@ static int get_conn_info(struct sock *sk, struct hc= i_dev *hdev, void *data, =20 cmd =3D mgmt_pending_new(sk, MGMT_OP_GET_CONN_INFO, hdev, data, len); - if (!cmd) + if (!cmd) { err =3D -ENOMEM; - else + } else { + hci_conn_hold(conn); + cmd->user_data =3D hci_conn_get(conn); err =3D hci_cmd_sync_queue(hdev, get_conn_info_sync, cmd, get_conn_info_complete); + } =20 if (err < 0) { mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_CONN_INFO, @@ -6836,9 +6839,6 @@ static int get_conn_info(struct sock *sk, struct hci_= dev *hdev, void *data, goto unlock; } =20 - hci_conn_hold(conn); - cmd->user_data =3D hci_conn_get(conn); - conn->conn_info_timestamp =3D jiffies; } else { /* Cache is valid, just reply with values cached in hci_conn */ --=20 2.35.1