Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3239509rwb; Mon, 15 Aug 2022 22:02:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR7/xNFs8aZIqIHeJwyUXCDUHNZKHc33j2qBaPzFT7k5MQx85EtRGbN1eDEpf0IoByXQ5BqP X-Received: by 2002:a17:907:7609:b0:730:d70a:1efc with SMTP id jx9-20020a170907760900b00730d70a1efcmr12353896ejc.766.1660626138203; Mon, 15 Aug 2022 22:02:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660626138; cv=none; d=google.com; s=arc-20160816; b=FvROkd3UVpZ7K4zczWipXuUs/My6hB+W6/4i8knbFYky/xns2sFWHrFgL24w8nezFR 22FqRjKVqCO8I4DtMdqsLUjyr6RqdDTOtxawywinRC4FHy3zveLqXoQParFNC8E3f2cD +JLRzDyr/faj3FyFymuwlcJv7d52969qUGBNmDxMNHBIDa05AVGDQ8U5zf2XJNnKy/9R u1+R507NTJ4SV/KhZJU1Gf7q12EsvrK2RSaD1ZAfqAV73u+8C/AM5pCi8x57TvIfzirh 4AAztkB3r2cigyz1TWjfazISGym+YFMGCtbdtI/DUlKh6YgVCPOMJ2DD9mHwD1gouaci jrow== 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=bAmYyCElNcf4OAUTjUOZeFCXrmlVBy/9Mrb1l7fBCp0=; b=KYCKoOLvJuaBKI9+wLhLjZskTo64qCT9ErHFsxY0R4MdR7nvGqhg1YCTHxyLt5j62H WOGavHt8pRot0ieH8paIzDWkKkzbl3br1imXItABbHLVy52Bg/dVv+Ab3IXXviYdCuXW sppZP8iuGWHEmVUrKShWB8jSwvr9T7ittnBQXhwJJqdFUks0UM6y3J8KW+4kPgkOWsK/ dPKuD+FeEqGcDrGNHGr29fc4cz2xqVtr29SrXxCS+KH4Yuvvzt0rJMrOYjsWGAUU705X jX67YN8EgxAfoZqx6qx/4WFloypvaetnan5VA2fQbB3D3A3TenVp/3I3Gn/gcVoK2d32 SzYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=b9z0UAYf; 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 hz5-20020a1709072ce500b00733016bd060si11659062ejc.139.2022.08.15.22.01.51; Mon, 15 Aug 2022 22:02:18 -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=b9z0UAYf; 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 S229756AbiHPEbD (ORCPT + 99 others); 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-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 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 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, @@ -6836,9 +6839,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