Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp875287iog; Mon, 13 Jun 2022 15:05:29 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sHNLM8Jp4evMiue/Cf92Ez7Z2y7UJcbKDWDZ7NWmyiw6x8WQX2SS3M8/eflrRBi4MqqIi3 X-Received: by 2002:a17:902:f60c:b0:156:82c9:e44b with SMTP id n12-20020a170902f60c00b0015682c9e44bmr1055560plg.106.1655157929124; Mon, 13 Jun 2022 15:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655157929; cv=none; d=google.com; s=arc-20160816; b=p63x2omErZ+Pjmu1qtbZe6ZxwfqqiAmfe8VmalY8msDw3L4XwyZbIdS1GJWrhJ+eIe LvB5D3Fs1td68AuzEr4ory3QmfKJXFFv5sS495G59oubGm1bm1RuFrK1QjJ8KHM+4Osd u9duFl57rTw7yqu2WSjgVBM2QrvP7wNdDS+pAzlI5H3CgYoYiEeVg+0g1wNVx5JyRd5a jiPLm0nlNQSSIeDouYpkKm1RIro0XoC5vo0Qh6Da/b250dSae6C8qmU5wMORo/4cYspe 1GXsPD8bkvlV4phA9S/YKEjcxv23MiwCfn0rNxzVCc2EUgNfD9Z6Idg35gszogxU5leb f4fA== 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=HWnkTBZLqQs4ZAkOxWrVH2dh0GaIG/x6FMFUGX9lOITGlx/Tkofmb2xxZdZ9sm4Pb8 cbiNTuQrzasQ7tqYAD0AzGdZRIWy/it8grGVN3F03Pe6OSYuDK7N5YWy73IuFNk+8/j0 LlikAvw+NlLlIIhJZDkWicidW3RpOxcCcrApy85N0sQIh/0bIfX2Ni1BQuWhFKJg8KSW 8yBHi232GNFlOZ+vgMiQMtOfBYvQQzmqRhm776m6t1Xmo80tFl+iT/7rbwqKQ0whzCDb XWEzPs1YAFYmfuB5/rsu95L0e6wZ40MxlYNeSdOR91BLW+ldOrQlKT6AptGrZwH1ibzS 0c1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=RfOQUrYJ; 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 68-20020a630347000000b003fbb3ea3390si11018355pgd.189.2022.06.13.15.05.01; Mon, 13 Jun 2022 15:05:29 -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=RfOQUrYJ; 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 S236145AbiFMVno (ORCPT + 99 others); Mon, 13 Jun 2022 17:43:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352286AbiFMVnf (ORCPT ); Mon, 13 Jun 2022 17:43:35 -0400 Received: from mail-pf1-x449.google.com (mail-pf1-x449.google.com [IPv6:2607:f8b0:4864:20::449]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F040E63A3 for ; Mon, 13 Jun 2022 14:43:33 -0700 (PDT) Received: by mail-pf1-x449.google.com with SMTP id z186-20020a6233c3000000b00510a6bc2864so2848642pfz.10 for ; Mon, 13 Jun 2022 14:43:33 -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=RfOQUrYJ7JQYov7qHkHG0D3CZvnSFd0EoNZxA2h9so3t5ghC6pS+NNf1FUtITajexh 7gUCIGccN3LwOTdXDbBwTD7+XrbjD2eCTvMc+5aogoJg1NLhjoh/3JkVtiEXluDPD8/L 62qDQT3rOniALV5GkhgmyKlJ0ekgyrY+4qVRR8hFt1yxoFe8SFc7VrHnqhP4/alrQ73A c9U55RUCY452wxUYwC2/CIcZF5HS7c00CsCKbWjA9q8EMErbMw8OpDaDmyFENmglX0pi VcnxlZOluUestMBBMo1Fj+JfcG64pqGogk3OFtPZrn7i+1602wbbcfm481/yPdWJKvJk 6tbw== 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=y8FqJrESu6NKoIuCrvEgMeH1E2anNn4DtONCWkekGsvtgrsTvI5+X3OVaoqEH4IJ6X VWOvTAy4KsM26xJxCsYQGOnxSYGgEzB3FMz43GrY6QjZ1sxCAQtcnjQo89OxsJgtB+BQ BiB8DYF1TLDzBU/S3/G/scVz/UBPAgoJ5jP9You8pTQN3p9Hx+MwFRHnfzmTcyEtyny8 cP5GL0e3ZmAmGiN8KiiybyGfvas1D90HkjGsMcP3K4fRSqLDq1B6SD7Ciuwb/rru90s1 Pjq6XszDGDFXKGAZhaxdW4kIrBZLnuhovfd+CEzwJS6gj9jkLpUkFjcQVyJrLikszPKo xYtw== X-Gm-Message-State: AOAM531ZbFOD9iCSY2S+YDqmAa4KWL/hqJwjFjZCOQahsYYljfEz0qZ/ SX81ubLylrRCNJIJFj/NQkE+ugMgdpx38p8UdOdxbgtVC8RjqEHQrc0+8kFHT1GSDeJl1CQI/mD lcZVfhavi65NoJpZTgK/QEoHM6a50Ul+arhz65EwNpBntR3Nfaq54rNuwk8ohBuddVgHcqPTEeF 5O X-Received: from jiangzp-glinux-dev.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:4c52]) (user=jiangzp job=sendgmr) by 2002:a05:6a00:b51:b0:51c:1219:569d with SMTP id p17-20020a056a000b5100b0051c1219569dmr1278341pfo.2.1655156613295; Mon, 13 Jun 2022 14:43:33 -0700 (PDT) Date: Mon, 13 Jun 2022 14:43:27 -0700 In-Reply-To: <20220613214327.15866-1-jiangzp@google.com> Message-Id: <20220613144322.kernel.v1.1.Ia621daca5b03278ee09314c59659b64c901408cf@changeid> Mime-Version: 1.0 References: <20220613214327.15866-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