Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1677857iol; Fri, 10 Jun 2022 12:24:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGOwjLFI+CLD77hzNX3U1gPPfwAc3djLzQs5aj2mDgLRIYpqNjO8wsx63ML8xqXjkIWPn2 X-Received: by 2002:a17:902:c407:b0:163:df01:bbbc with SMTP id k7-20020a170902c40700b00163df01bbbcmr46463842plk.4.1654889063097; Fri, 10 Jun 2022 12:24:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654889063; cv=none; d=google.com; s=arc-20160816; b=Hl7OPYegBjlb2T0Oy8Oyly47U68stDMMYaiF+/0reTkunZf66MIqfzrpM59sK8gvE8 /r0U3WrndCIZjfZBb3TcDznAIeOO4ae13p8jyhqUyG6K9GUSI5ECSzmufRSc4Q4XL5gj Aldph+DTKX2Y4R5849wmDXO3kOc0N+GJOsaZ1rcR4Gea+mVbeY4V8Tu4RSkbCcmcoGbq YZoO9LVnq+9yfIAVxUw58p5AKk9qzVZyWHUnUZgyoeKKwR6UMJOo3/1XGcDEb6Jx01em 8Ig5PkOaIgpYfbdxUCbTv0nO+24BDBjRDzLJJvOqCbEaoNe6w0eAn6UTcGBGlLM7UOqp Rq7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=+dbqcGyic4c3zYFWxW8WIDheVsDHS+XGvESBEzG7d5k=; b=u0SywE8EmKnzaT8HvgJLLMh+VtyeBJ+BELTHjD+NriFaYLh33FzAxbsrqMNx6OhhUZ /HbS6yIPNwcv6Ll0YHJNOSZwaZFrVBeSqKgGYQrAp9h51bGqGCTMOkoe7U/uULgQJfyS RO/6tDVKBjBuBQklNeP28fW6IyHue4kiVBSWxffxkfLRjqNM51vhS6EwNrKJCKCByvu1 WzcERsdi4+2hLqyRbUpnTYxHH7V0r82+IM1gbBM7nI0dUuO7drOseclhqlJ24s1kGsHP j/df71q67dFWFAqEx0IfINO7ayvlZAOhkJML2yms5ijYtjpaRbwS6JzIh5rmIlrSRqBO C05Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=VJWfSHAO; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w15-20020a65694f000000b003fdff346287si13297667pgq.674.2022.06.10.12.23.50; Fri, 10 Jun 2022 12:24:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-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=@google.com header.s=20210112 header.b=VJWfSHAO; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347775AbiFJTUC (ORCPT + 99 others); Fri, 10 Jun 2022 15:20:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349805AbiFJTTz (ORCPT ); Fri, 10 Jun 2022 15:19:55 -0400 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17ECC2C651 for ; Fri, 10 Jun 2022 12:19:55 -0700 (PDT) Received: by mail-pf1-x44a.google.com with SMTP id 144-20020a621496000000b0051ba2e95df2so98886pfu.11 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=awTQEJ1kZlYjClLR9FQZY19ksGf0mMY3nqg/rfSexayOyb3PSOzuKgCvFGLkfNBHhr hyFKN6g6nSnt0btqE1KEjtAGYPD+WgUPaKWXEDO5Hnt/ern9Oemg5HZzZ0ziN8Hr1xpM U3CazIvRtCbhAoLbgEEGTVrl7ZIO6nPq/chAJ5HAdUWfocmYHLxATZ5Z9pa9BEiANof7 Lnazq1fEcylZbqmCkSdKoFtgIfVMGll5qKLu3omP2DDrI42iR2YgwXNtQLDGK2+sBs+b Rbkv6VPPP97Z8rRvt9AZPodroozzi0ZrXu/MnjiFDn0bawgkuy0X+EZxgEtWmi+QviNJ g27w== X-Gm-Message-State: AOAM533qyV8MCfv4mQvpmOdbQEDS5wkQE8sfWSRHl4tH9n+MVwN2FVA+ nlaB10UpG/hd/t0dzJRpQiwaxLZpyOl5sHsX7q0hur+cjagU9ACaIlbzqHpVJAULo1pqzY2G6JR zW53+ZKMChWQsFMdVUbJ0d/1tLu0Khv2sKQCrMebGeNWHpd1g7g5RsuCwc2j68Oee5pzbkbwUFk 3H 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" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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-bluetooth@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