Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp42754imi; Wed, 20 Jul 2022 16:40:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sNrUDedeLpy0gZ10ryIs7+AuvXQgGCFZE8/lSSZyQoq5DavCjXneAKcHdQFDZejX5mI8Oq X-Received: by 2002:a05:6402:5244:b0:43a:77b8:6bdf with SMTP id t4-20020a056402524400b0043a77b86bdfmr53076885edd.153.1658360406262; Wed, 20 Jul 2022 16:40:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658360406; cv=none; d=google.com; s=arc-20160816; b=DkS7dSDxysK/kq9cz8QjcG+ZZDyKBgtqYHMOYze9P9OxmTgmKZb36NOEXS9c74QQiG MuHYLyxRbJ7r+CsslSEMvSYsBex7McmjmmdMNCrDNXdBMG/tljjeNewMx6id6j0X2oVy h8Yft7T7jvV0IuNqt6A9TuCIl39khCnp1PInm1xain4bWxQR0bitjYtss13cvJxZ620C hU1yATq8ivoDEpFy9a0sW6Sj+2+jvyAnXnCKdh7LEGUJzG4XIRNXdMGxU2ZqY18jOgQN Hhljcv81fGqQoOI4GkzpuHOoIvy5jm2RSyzf101yQe0Lb6bcvYOX13Crc5MzdGRA9u7U 1ZOg== 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=GDwNRahEvWVru+BxuIQ357pQqacVUlD5qD0z2khJ2K4=; b=AGrsFOWxe06EtnR2ZvuYNQDbuiab6aZY9q9HvJADba9eafODzZyE8qzk7wbN2Unx27 mrmgzcw88WPonCpZtY8uGD8OZ/U0LzZUvVYgTwws0Hg+F5yg03Uqi+M0aEpORhLd8OmV C1zbP7x+IrzdxdhkQ/akDYdpfTzwFRBKr5ZWHC6i7nDc+UkC782skjzohEpDrIDkTpvC hwxYxuPfqR0psDCNzVtWgraNntSE6Uu32bpExLHHr3oVodDkSZ7fMB6o/K4Po46rixW4 xMehR/awxC5ebMwtvfFnbn1frdtczCqvxLJas3GepLYcHQG/SxxAM9J2c7YecYqIow78 3BcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=VrsvfhRK; 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 kl7-20020a170907994700b0072643608fb8si529538ejc.953.2022.07.20.16.39.40; Wed, 20 Jul 2022 16:40:06 -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=VrsvfhRK; 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 S231213AbiGTXgQ (ORCPT + 99 others); Wed, 20 Jul 2022 19:36:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231138AbiGTXgN (ORCPT ); Wed, 20 Jul 2022 19:36:13 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98C485B7A3 for ; Wed, 20 Jul 2022 16:36:12 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id 92-20020a17090a09e500b001d917022847so12933pjo.1 for ; Wed, 20 Jul 2022 16:36:12 -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=GDwNRahEvWVru+BxuIQ357pQqacVUlD5qD0z2khJ2K4=; b=VrsvfhRKl3GnAone5U2wVtFFO6UfaZsMYXffB4ScA0q/j6Y/siHawxs0uMimIPnJuG 2ahwGq8RstSCkN+6XIC0mA75b7qnatLNoEkSysD+VS5P96hUChXPdeXVRNX/Aw/DwXjd pl280vlxCCf7O8MbIaDDBjbdKtpioP36T/gH+8E1AkYOlXndi38sTCUbA7pQKYB3xTZ1 DbGXTl5kYhZL0ABkxAjruREwpWPlMLT0+HGoNSqBqA7sE4I0eI0VfZ37e+81qcR0ZM4U MYgqMDJkzMMcRxjVn/utsQrZIXQ3cX6HCFVL1P/D0OK7uK/s20r1uhD4j7bKdKbHglV/ yRxw== 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=GDwNRahEvWVru+BxuIQ357pQqacVUlD5qD0z2khJ2K4=; b=Cn8G77mHRTRN0yXENX8/M//yaXO8nUYh69xFop0Qwyhp3XP/pNQL8iJup00WYca0K+ bWfbMfQDAS5qJIou3wVIrcOpkPx7qSruHdmhIQ2coK93h1WAqR/GKAopTR88jqDnE44a HRo1UHptzfI7pShmy83wRzdQR5h+HqTWl9dKWCFwEGVDkuWgZBXT5Es7FXJwqa2y+hxh 8DG0QLvAGvo/gsiVkag6We7VPF7wXcV0XVtHEXPjnQ8AFSPlrPgkCnE60bpocoiuj37C g7FbtvSX6cuYZ8FaEMsTltEbRSCKCvnjrzWkYrR7QSZlQG0RMInTjlH7CBy4rkacCKiY oyjA== X-Gm-Message-State: AJIora+nRRt/RfDs7U7FQqYt6zCKA2mZmz8emlVjTWNYDx1ZcU0QfY1z hAUVqxtozGevbmydLXADjUOl4JZZTLqwdOmG6R8UrGNpukDLh7bvdvXslas8AqmUFGwqIge8YWt /YeNJWyd2CRdSebh0wTPIBdFdRk1AX2kEJxuNWubPiaP1G9TxDjvaxKv5LlQlGOnWNs1wafH88+ BV 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:1145:b0:52b:78c:fa26 with SMTP id b5-20020a056a00114500b0052b078cfa26mr41061144pfm.27.1658360171954; Wed, 20 Jul 2022 16:36:11 -0700 (PDT) Date: Wed, 20 Jul 2022 16:36:01 -0700 In-Reply-To: <20220720233601.3648471-1-jiangzp@google.com> Message-Id: <20220720163548.kernel.v1.1.I4058a198aa4979ee74a219fe6e315fad1184d78d@changeid> Mime-Version: 1.0 References: <20220720233601.3648471-1-jiangzp@google.com> X-Mailer: git-send-email 2.37.0.170.g444d1eabd0-goog Subject: [kernel PATCH v1 1/1] Bluetooth: Fix get clock info From: Zhengping Jiang To: linux-bluetooth@vger.kernel.org, marcel@holtmann.org Cc: Zhengping Jiang , "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,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 If connection exists, set the connection data before calling get_clock_info_sync, so it can be verified the connection is still connected, before retrieving clock info. Signed-off-by: Zhengping Jiang --- Changes in v1: - Fix input connection data net/bluetooth/mgmt.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c index ef8371975c4eb..947d700574c54 100644 --- a/net/bluetooth/mgmt.c +++ b/net/bluetooth/mgmt.c @@ -6971,11 +6971,16 @@ static int get_clock_info(struct sock *sk, struct hci_dev *hdev, void *data, } cmd = mgmt_pending_new(sk, MGMT_OP_GET_CLOCK_INFO, hdev, data, len); - if (!cmd) + if (!cmd) { err = -ENOMEM; - else + } else { + if (conn) { + hci_conn_hold(conn); + cmd->user_data = hci_conn_get(conn); + } err = hci_cmd_sync_queue(hdev, get_clock_info_sync, cmd, get_clock_info_complete); + } if (err < 0) { err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_GET_CLOCK_INFO, @@ -6984,12 +6989,8 @@ static int get_clock_info(struct sock *sk, struct hci_dev *hdev, void *data, if (cmd) mgmt_pending_free(cmd); - } else if (conn) { - hci_conn_hold(conn); - cmd->user_data = hci_conn_get(conn); } - unlock: hci_dev_unlock(hdev); return err; -- 2.37.0.170.g444d1eabd0-goog