Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp49316imi; Thu, 21 Jul 2022 15:44:26 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sH0ioOPfJAjXe0P0EkfL5fmkdYB54Di929lA+AwcgS9VgkPkN9JaH+clByH+6G2me4ZZ6E X-Received: by 2002:a17:90b:1e04:b0:1f0:61a4:d747 with SMTP id pg4-20020a17090b1e0400b001f061a4d747mr13837897pjb.58.1658443466599; Thu, 21 Jul 2022 15:44:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658443466; cv=none; d=google.com; s=arc-20160816; b=N/o349D+UeqFPV5wvkHbnknd7AR+eRKIpZpyO0hV0Qfc/lHrEBOElsKGtSPDX4APgG aqKoZJLuwSiGgnLQ2ur0j8lpadP0i5Z8f1JelBWsclT2gJB7HCDdj0TUBGDN2DgULrqL uFRjiI+sO5kCenHiYTa48noJzBuJF9RDEkkEbGnu6/hF9vgcEHNbVOYa0M52VC/WW4Cx gUSb78nzwyKUFe/dL4pctXE7pdYVHyGiq3bnxNQ+VRQtTHVk0GFS2DtUmPVdxssQ3msV ysS5u0ctUpbI4BqVlDaKV4qNrwz2HS5VXfRW/1fXm2lnV7C8rC86cVEjE4iL2eETi4Pr cQVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=5C4cxe+SIKwFqqDzcnUQnDBoYOsEdyQ06UoX6upJT20=; b=j4cuNeZtTdaCxPcWPq4VdawIEKVcJWha/A38YYnXbWztDV4fQcMib8WByNg82XQwV/ jk9mkmAqyL16arPtscrpXl6zY2LKC5Pak8bKxFE+83z9UHJATzYytovRpG0OOkCqptVO /VpScp6ZxtDsCN/lDoV79yB8mi3XbQLCs5orATTmsrpRZIhBsVks4sBzNqQrF9ill5e4 FGM+HKISnHv5DiqitGUqs7pdK6k/6cbvzlGMhPgSW1ymQrBm0Lyts0/w8aGb92QbZS7G Z/Ejy/6ZqRyNg0PGTFSUZpbtbVUT74Ezgv0OjRNiUvO9S3BQn3U/uNLdNEwPWRrH7x1d kj8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NP3VvhI8; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v1-20020a63b641000000b00415c6084bbcsi3827859pgt.739.2022.07.21.15.44.00; Thu, 21 Jul 2022 15:44:26 -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=@gmail.com header.s=20210112 header.b=NP3VvhI8; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233672AbiGUWlL (ORCPT + 99 others); Thu, 21 Jul 2022 18:41:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233520AbiGUWlK (ORCPT ); Thu, 21 Jul 2022 18:41:10 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC13178589 for ; Thu, 21 Jul 2022 15:41:09 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id bp17so5049978lfb.3 for ; Thu, 21 Jul 2022 15:41:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5C4cxe+SIKwFqqDzcnUQnDBoYOsEdyQ06UoX6upJT20=; b=NP3VvhI8UbXY0390Hym9wzA1VoCG2qOz+KByR+9v/jWD6Cs8d05T2w6QwyAHj0psCg 38Ts3bn61k8CRefFsXcRgpSeRIiLx2H8OBb7bPVLGyl6KEO1Im+ESVXWrCSGAKwv52NW JlaIGV0+nNqz2mfkYTdudtyenBfz3e9W0V6MpAHyCbVSUlwjzBDSUh/xqHU5xsWdJoq/ 79+9icSZo7hh2S16tgta1ziYRQgm8rGFigaYjBTZ16aHwoejxFMyvO2FZcVJHUh1bsMF VmunKsuwy7TiQKN8Ihup/KGzVWspKSsQFIFwpB2q6A6qkGmyTrBybOnx2AjVU/sc3jcr HyEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5C4cxe+SIKwFqqDzcnUQnDBoYOsEdyQ06UoX6upJT20=; b=UWhEe9Wbdo6n+9AUiqC6xtk1khTCI6eNOavCzvvx6Y8oYAInzBxW1ljDd0E93XOEJs wwCocgjTVDmMjuCisDq/YxM76I7Fl/hZ9+C+T5FwkaEk72cPjHYtqYs6USKH22+SIjjb rZfF1gVgqTqL60ONrf6akPkUmiFma+O7ez1MtiHHRV62HrXbpJob0p1mYdxc4qxAVIDw Zdh78aJhpbu06OXbBiCF95Fqf7At6B3+sHQspYiyt6PFOEuqc3q7lPw2aCr7Jx8ECXFO aU5mkFQq2lBeD0GpXFwsa6MIKfRQMfYDYOMljubRisk5I2/+/KtsI6joP1qv2JFG0Eqo nSCg== X-Gm-Message-State: AJIora+J6UtMSroWgu0dWejTV/JHCNaIKPEB1Mm8REEjzmbC9NajRhZI ERGa5d30gDI38JhLN+5rFqMa1ejkfaJnzzvJotu7kmac3GXXNg== X-Received: by 2002:a19:5f4d:0:b0:48a:7001:dbf8 with SMTP id a13-20020a195f4d000000b0048a7001dbf8mr188314lfj.251.1658443268148; Thu, 21 Jul 2022 15:41:08 -0700 (PDT) MIME-Version: 1.0 References: <20220720233601.3648471-1-jiangzp@google.com> <20220720163548.kernel.v1.1.I4058a198aa4979ee74a219fe6e315fad1184d78d@changeid> In-Reply-To: From: Luiz Augusto von Dentz Date: Thu, 21 Jul 2022 15:40:56 -0700 Message-ID: Subject: Re: [kernel PATCH v1 1/1] Bluetooth: Fix get clock info To: Zhengping Jiang Cc: "linux-bluetooth@vger.kernel.org" , Marcel Holtmann , "Gix, Brian" Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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-bluetooth@vger.kernel.org Hi Zhengping, On Thu, Jul 21, 2022 at 3:20 PM Luiz Augusto von Dentz wrote: > > Hi Zhengping, > > On Wed, Jul 20, 2022 at 4:36 PM Zhengping Jiang wrote: > > > > 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); > > + } > > Having seconds though if this is actually the right thing to do, > hci_cmd_sync_queue will queue the command so get_clock_info_sync > shouldn't execute immediately if that happens that actually would be > quite a problem since we are holding the hci_dev_lock so if the > callback executes and blocks waiting a command that would likely cause > a deadlock because no command can be completed while hci_dev_lock is > being held, in fact I don't really like the idea of holding hci_conn > reference either since we are doing a lookup by address on > get_clock_info_sync Id probably just remove this code as it seem > unnecessary. > > Btw, there are tests for this command in mgmt-tester so if this is > actually attempting to fix a problem Id like to have a test to > reproduce it. Looks at the other change you submitted that has a similar code pattern I did the following change: https://gist.github.com/Vudentz/91cd57373d5b0116e2c34b6fb6adaa07 And mgmt-tester seems to run just fine with these changes. > > > 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 > > > > > -- > Luiz Augusto von Dentz -- Luiz Augusto von Dentz