Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3027210rwb; Mon, 15 Aug 2022 16:25:31 -0700 (PDT) X-Google-Smtp-Source: AA6agR7vtm22N4NuqdEpdmRYPpDyjfp01xdc1TTDCOB4UHFvqxuwRs7hotGmu5zIsUOnVl4AsxjS X-Received: by 2002:aa7:dc10:0:b0:440:b446:c0cc with SMTP id b16-20020aa7dc10000000b00440b446c0ccmr16446796edu.34.1660605841422; Mon, 15 Aug 2022 16:24:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605841; cv=none; d=google.com; s=arc-20160816; b=CD9LYwxPqIcueP/vXQ98NpQnTaqdO8LLyxLVj6cB+l5fH6u9bbE6JmlV4GYMrFnTU/ BNHft4JS303KQpnfo7gh7k2HOfwfAyXtcbxi8Fol/SqXl7BWxveklHp37xmKPezWb046 hRvkA78DSGbp95l0O7q5kZnL+6+z1wC3KLkJqB6VX1I0xRUIBlY3/YhNaFBgPGt0H+Wn fBxQ0isXosCc4flONxI6xBy7J3k3yJfPdeFkAEPsIZ5ofcK6/7cGl0jGupct4VIEVmgF wJgqun/VEPUie8L2+o1cl9RgrvA0EU66AeyIBNHwRO30mPx3C8oFDPCqpRj5LCT9UbCm ZQ0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3VQqNuDjbG+eIgh6CG/RbFLxGOg1qXDHsQsdSdI5Bgo=; b=Jl2tn0wFJaGLIGp1N2KSC+1hyiF/2iKSgJnFasm//5avogBcJziNGvpDFCyIjbLeGx Pj2ZOsY14XKJ89w39BUhg53hxLgsw1u+HxVSIxR+LifINR2vIY/LcB9Ru6c6G3yBtxOw q0ePk0qN77JoePztHtPjITs76r1UnOw0hHHv0z2ahYOKCFgJXWXG1DZGODE5EtzBMN+Y 6Y08uvC8akAMbZfU3tVhlD2r/b6TLeSqUiX4jrAuq5Tc19pUEz2Ei7P1D5fidGHXL1CV 4yRKohRdbKxuRWefnvxFs68wR5HsrpnGoOQvns4/nk8GKOrwjRFWi01j1iBFABdiu8a0 ZAxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kW6xDWjH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g14-20020a056402428e00b00443ccd1dd45si2647718edc.189.2022.08.15.16.23.36; Mon, 15 Aug 2022 16:24:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kW6xDWjH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241080AbiHOV2D (ORCPT + 99 others); Mon, 15 Aug 2022 17:28:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347668AbiHOVSj (ORCPT ); Mon, 15 Aug 2022 17:18:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F06CE3C19; Mon, 15 Aug 2022 12:22:01 -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 C3716B80FD3; Mon, 15 Aug 2022 19:21:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03F00C43142; Mon, 15 Aug 2022 19:21:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660591318; bh=C003x6BECaOjQ4JdOh/MX9egyER9MLtoCYxgZdpOtUg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kW6xDWjH8ocsd0HViLXlLKWWFHbTCWwHYy0o5Npwis3+6528wYHr+Yejr6iTlTwVy 4nFYkMMfRKuuTyCX+2e3cDViuPioZ81pVhK9DeoZJtO+9PGEdsafld9yx8/R4/ql3m ZwJYUj6p0WJo+uzSNFaYoS2mEimox8TTguEefA94= 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.18 0497/1095] Bluetooth: mgmt: Fix refresh cached connection info Date: Mon, 15 Aug 2022 19:58:16 +0200 Message-Id: <20220815180450.092211146@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 ae758ab1b558..12c1ecdba3f3 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -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 */ -- 2.35.1