Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp922931ybz; Fri, 1 May 2020 11:01:52 -0700 (PDT) X-Google-Smtp-Source: APiQypKblNjfDnfL6TtDsXREIrmcHAY/qoa1iG5b/KogZM4aVq9qm6lMzpmSEyewqecvdXy2wmHD X-Received: by 2002:a17:906:534b:: with SMTP id j11mr4247172ejo.142.1588356112107; Fri, 01 May 2020 11:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588356112; cv=none; d=google.com; s=arc-20160816; b=FX5MSF1FGFsAjyg2K+D9xhHG6pFcYqRDQEmKGuswoUqQGXx7QtDTbNF+WFkh1PDox/ R6FhrXZpzbu5ohWixgc7Gqt3UEPrJLBKbiF+1wiDMtfmoKYm/Bnkbqc15aaADGgzTReL oH1iRsaruWocH6uDzWFV/OqiIZiUB/wUZJRz0mEvZ4yHnduot5v1dJtvb26w0UU/FMsl OFvWXpkxsrHdibkFfTuuf73nRKwS1jENjk3jkmH+ih3lpxzh6aoprhF6JzC/n1X+PRVy yWcadnFnb+xxiTGRT1C4/CJRb0tISFu4KwedAehm6B5v/getxiNQDuASuS6It4wNiOa2 iAwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=WcfjuDnM6VZ4kA5rArurTTkq35240DD77KqFZ68J7ek=; b=T8437SEz8rjWaXRZm3oofQUedmhfaIFinxspGd5p5g6ksOVa38TtAWJVEDt2KCkTT7 yKky42WntNTgcYV6MNkdU/HHjlY4qGc3PqmYmaO42lJjvUea9h7eFQnI4jWBcX2bcV9U gkLWxlClYMInqfgp1BFGTtqKPe+HHQ7bU2sVYLdTvIqArlhLaUKfnhYyxeYnbj4m2hP9 uhDX/11S1Zdr7APSw7JgEmWK7o7ErSC/4FKMv8lGmkdlei//+Pod6iCeAlY8p16NShTn GGcK51gu7WlSr3MMXiz2fgLq30J+sIg8x21zKAinFfragKnPXkLu4QD6Wgm6VfSxGCCk KG8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f17si2396483ejx.11.2020.05.01.11.01.15; Fri, 01 May 2020 11:01:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729138AbgEASA5 convert rfc822-to-8bit (ORCPT + 99 others); Fri, 1 May 2020 14:00:57 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:52903 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730210AbgEASA4 (ORCPT ); Fri, 1 May 2020 14:00:56 -0400 Received: from marcel-macbook.fritz.box (p4FEFC5A7.dip0.t-ipconnect.de [79.239.197.167]) by mail.holtmann.org (Postfix) with ESMTPSA id 8816BCED24; Fri, 1 May 2020 20:10:35 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [BlueZ PATCH v1] shared/gatt-client:Ignore orphaned characteristics From: Marcel Holtmann In-Reply-To: Date: Fri, 1 May 2020 20:00:54 +0200 Cc: Alain Michaud , BlueZ Content-Transfer-Encoding: 8BIT Message-Id: References: <20200501144037.1684-1-alainm@chromium.org> <4195BFB9-1586-435F-8FC2-ED215959A591@holtmann.org> <215E5E68-A360-4DD7-8DBC-E46278729FC6@holtmann.org> To: Alain Michaud X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Alain, >>>>> The gatt discovery proceedure simplification to discover all >>>>> characteristics at once has exposed a device side issue where some >>>>> device implementation reports orphaned characteristics. While this >>>>> technically shouldn't be allowed, some instances of this were observed >>>>> (namely on some Android phones). >>>>> >>>>> The fix is to simply skip over orphaned characteristics and continue >>>>> with everything else that is valid. >>>>> >>>>> This has been tested as part of the Android CTS tests against an >>>>> affected platform and was confirmed to have worked around the issue. >>>>> --- >>>>> >>>>> src/shared/gatt-client.c | 5 ++++- >>>>> 1 file changed, 4 insertions(+), 1 deletion(-) >>>>> >>>>> diff --git a/src/shared/gatt-client.c b/src/shared/gatt-client.c >>>>> index 963ad619f..d604c77a3 100644 >>>>> --- a/src/shared/gatt-client.c >>>>> +++ b/src/shared/gatt-client.c >>>>> @@ -632,7 +632,10 @@ static bool discover_descs(struct discovery_op *op, bool *discovering) >>>>> util_debug(client->debug_callback, client->debug_data, >>>>> "Failed to insert characteristic at 0x%04x", >>>>> chrc_data->value_handle); >>>>> - goto failed; >>>>> + >>>>> + /* Skip over invalid characteristic */ >>>>> + free(chrc_data); >>>>> + continue; >>>>> } >>>> >>>> should we add a warning here? >>> Is there a good way other than the util_debug mechanism to write a warning? >> >> you could just use btd_warn() here. If this gets too noisy, we either remove it later or we introduce a btd_warn_ratelimited() or btd_warn_once(). > This being under src/shared, I wasn't sure if that was acceptable to > add a btd dependency here, especially with the work to avoid it via > the util_debug. Happy to do either way, just want to make sure the > guidance is clear. good point. My bad. You better leave the logging out then. Regards Marcel