From mboxrd@z Thu Jan 1 00:00:00 1970 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 B12ECC433EF for ; Fri, 10 Jun 2022 19:20:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350097AbiFJTUE (ORCPT ); Fri, 10 Jun 2022 15:20:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349774AbiFJTTz (ORCPT ); Fri, 10 Jun 2022 15:19:55 -0400 Received: from mail-pj1-x1049.google.com (mail-pj1-x1049.google.com [IPv6:2607:f8b0:4864:20::1049]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDE6027149 for ; Fri, 10 Jun 2022 12:19:54 -0700 (PDT) Received: by mail-pj1-x1049.google.com with SMTP id k92-20020a17090a4ce500b001e69e8a98a4so78047pjh.3 for ; Fri, 10 Jun 2022 12:19:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=+dbqcGyic4c3zYFWxW8WIDheVsDHS+XGvESBEzG7d5k=; b=VJWfSHAO2Je3tlWHbkl6eBf3JQors99nQSoFMQw5AngSQ7uNthpdVTVVO6if8U823B Wu1S8b2rx3Ak6ZkOk6+AwA9gGBNOOThMx8xQHTEW6s7PY/nUBi2uIclkac9x4cTHvxmo y/AJXy2aaupC/ITuM+2EZT3d4ceiyjYVlx4GC0SwtlZuKBtjFcy8EeMDNXQjTjgKmwiO YMx+HsIRaSR+hgiXac40qw+UTiQ5bhIIl843JQc3xND8j8ThTL2i79J9eJ9I2kPOTUhP l8UN1bhL572rWtU7JWt1Y+XqSDy0cbu4e8aGAxD0ZcWNoS6OGV3QWf79o7u/NVh09cqV 5qng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+dbqcGyic4c3zYFWxW8WIDheVsDHS+XGvESBEzG7d5k=; b=M2ivQ6Vwsz6UEE+LjnQJc2gAuRO2Z4BppNsWvqRVuxoY3tD7xohzDQ6vchTZcWEZTa U9wf+y2fdcXkHMGWzaDWzcER4nM/5MXsZsfoMK5mKVkAnFLulCy3rXHb3xtOP/Z7Lqg6 WPmK9QWwPbR8cZQlSs8UUEwP8StrYnIVbPvWwOBvpy5VQ1fzYzGtbDehc9b97xi6KMKr VrcDpi7PMmp0QjbRmMCTDSf25MMZdVxeDEg3/+ArUYl8xxk9rBNKPbYzpATEP+i7H9Lz hi305OJCoRKwc+BGLQwyUKFOxB1jBTSK4lQI8XC2QeAYagUdw2eeJ3JAovlBYSyZg+6K KY7w== X-Gm-Message-State: AOAM5302Wo+bDDN9c+nQvZKQAAFU3o9Z+7ywhK8Y23J52ACb396LiaTD p27gehQFxdo5jOIwHkUQTvtOcmm2r8Hi X-Google-Smtp-Source: ABdhPJyMdoK0Z7VltgUeKks6E5rfObRdmAL0gzme9n9MCpzTKMf4h5EvoDtvJMEi3EHvOfGfzYtIGm3btkTn X-Received: from jiangzp-glinux-dev.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4c52]) (user=jiangzp job=sendgmr) by 2002:a17:902:6bc6:b0:166:3c39:50a1 with SMTP id m6-20020a1709026bc600b001663c3950a1mr46022372plt.36.1654888794338; Fri, 10 Jun 2022 12:19:54 -0700 (PDT) Date: Fri, 10 Jun 2022 12:19:34 -0700 In-Reply-To: <20220610191934.2723772-1-jiangzp@google.com> Message-Id: <20220610121915.kernel.v1.1.Ia621daca5b03278ee09314c59659b64c901408cf@changeid> Mime-Version: 1.0 References: <20220610191934.2723772-1-jiangzp@google.com> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog Subject: [kernel PATCH v1 1/1] Bluetooth: mgmt: Fix refresh cached connection info From: Zhengping Jiang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org Cc: chromeos-bluetooth-upstreaming@chromium.org, Zhengping Jiang , Brian Gix , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Johan Hedberg , Luiz Augusto von Dentz , Paolo Abeni , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes in v1: - Set connection data before calling hci_cmd_sync_queue 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 74937a8346488..cfbea6fa04335 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -6828,11 +6828,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, @@ -6844,9 +6847,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.36.1.476.g0c4daa206d-goog