Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2557334pxb; Tue, 12 Oct 2021 08:58:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfTZR8dk9NLy7gANYOSEkQ4f+aqSoToXQgzH9707lMHizABiKKVuLxOTnoHEUEMNxTL9AQ X-Received: by 2002:a63:9d0d:: with SMTP id i13mr23165836pgd.117.1634054301351; Tue, 12 Oct 2021 08:58:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634054301; cv=none; d=google.com; s=arc-20160816; b=c9uZiP9wxFSjB7bkebS86NRZlC8mzyyVKsSx6aNA2cQL/1sXoxLrhFDES2AigXt1Cj MNzQXLqttkI6UNzVAMTbrUP8MEhGOjrKixxZyy7pcQT99DJxsO4sx9EDDxTYXti6kTVt uKlaaaRM6Emuv+Z/VBuTKd6k06wnHUn6Hbf20CTgyrggzHkG+5ZltPgr83/FUsgNCA0g 5ky63KCZvtjY6TqM8OAHFXYerBVUg012COdsoC5dU3vccoBcGlX4H1nbyCIdjilc9yIZ gRP1aTpTsPUAx4lYBu4Kl5pLKeP7UhmwvtCPZ453T2vtT037UfdVu64TBH99tV/If9Df 6Gww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=wJmOewx0UgGTOWwh4NA+RL2QQmz5ER/J+FXSUsdXPJQ=; b=0PIcW5GfWfRdVxVCGTqvtJuFnbLYRLWOM75GahTZaxujJWi1sN+30ZJNrfAx7AZJgs 8RNOkcfL0fhUAAIjw1tyA9BvEVLtCjZZc/nCfrsAYBcKOExaGLg6RZQxEh9Fwdjfh8ue 733azS503mJxtMKiEpOVnMqF/pfdoQRucALLAygbPc75Nb5CaJQuXW6tqm1DNQH1s+Pi tUFNfoQGCw3uafZbp7pHvy16nbrdR4HH5i7WGu//ksbfIiogBInQm+UF02z0feaHyT/X +7H2LwpkqfYoTQz8QDHopmzR+hjXsP3jp7qQwGEtokA/rtRzOpqyzqoHfCK7UjOHiaBi i8Eg== 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 bb13si3867298pjb.150.2021.10.12.08.58.08; Tue, 12 Oct 2021 08:58:21 -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 S237540AbhJLP6h convert rfc822-to-8bit (ORCPT + 99 others); Tue, 12 Oct 2021 11:58:37 -0400 Received: from coyote.holtmann.net ([212.227.132.17]:56225 "EHLO mail.holtmann.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237538AbhJLP6g (ORCPT ); Tue, 12 Oct 2021 11:58:36 -0400 Received: from smtpclient.apple (p4fefcb73.dip0.t-ipconnect.de [79.239.203.115]) by mail.holtmann.org (Postfix) with ESMTPSA id 5D9C2CECE1; Tue, 12 Oct 2021 17:56:33 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Subject: Re: [PATCH v1] Bluetooth: btintel: Fix bdaddress comparison with garbage value From: Marcel Holtmann In-Reply-To: Date: Tue, 12 Oct 2021 17:56:32 +0200 Cc: Luiz Augusto von Dentz , linux-bluetooth , "Srivatsa, Ravishankar" , "Tumkur Narayan, Chethan" , "An, Tedd" Content-Transfer-Encoding: 8BIT Message-Id: <23272CA9-FEE5-4E66-942F-E66FA1E513ED@holtmann.org> References: <20211005042613.9946-1-kiran.k@intel.com> <79B0A1CF-17D0-473C-A321-39E1BC291A89@holtmann.org> To: "K, Kiran" X-Mailer: Apple Mail (2.3654.120.0.1.13) Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Kiran, >>>> Intel Read Verision(TLV) data is parsed into a local structure >>>> variable and it contains a field for bd address. Bd address is >>>> returned only in bootloader mode and hence bd address in TLV >>>> structure needs to be validated only if controller is present in boot loader >> mode. >>>> >>>> Signed-off-by: Kiran K >>>> --- >>>> drivers/bluetooth/btintel.c | 19 +++++++++++-------- >>>> 1 file changed, 11 insertions(+), 8 deletions(-) >>>> >>>> diff --git a/drivers/bluetooth/btintel.c >>>> b/drivers/bluetooth/btintel.c index 9359bff47296..d1703cc99705 >>>> 100644 >>>> --- a/drivers/bluetooth/btintel.c >>>> +++ b/drivers/bluetooth/btintel.c >>>> @@ -2081,14 +2081,16 @@ static int >> btintel_prepare_fw_download_tlv(struct hci_dev *hdev, >>>> if (ver->img_type == 0x03) { >>>> btintel_clear_flag(hdev, INTEL_BOOTLOADER); >>>> btintel_check_bdaddr(hdev); >>>> - } >>>> - >>>> - /* If the OTP has no valid Bluetooth device address, then there will >>>> - * also be no valid address for the operational firmware. >>>> - */ >>>> - if (!bacmp(&ver->otp_bd_addr, BDADDR_ANY)) { >>>> - bt_dev_info(hdev, "No device address configured"); >>>> - set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks); >>>> + } else { >>>> + /* >>>> + * Check for valid bd address in boot loader mode. Device >>>> + * will be marked as unconfigured if empty bd address is >>>> + * found. >>>> + */ >>>> + if (!bacmp(&ver->otp_bd_addr, BDADDR_ANY)) { >>>> + bt_dev_info(hdev, "No device address configured"); >>>> + set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks); >>>> + } >>>> } >>>> >>>> btintel_get_fw_name_tlv(ver, fwname, sizeof(fwname), "sfi"); >>>> @@ -2466,6 +2468,7 @@ static int btintel_setup_combined(struct >> hci_dev *hdev) >>>> goto exit_error; >>>> } >>>> >>>> + memset(&ver_tlv, 0, sizeof(ver_tlv)); >>> >>> this change is not described in the commit message. Why is that now out of >> a sudden needed? >> >> I guess this is just to make sure the ver_tlv is initialized so its otp_bd_addr be >> set to all zeros (BDADDR_ANY) otherwise the code above doesn't work as it >> attempts to compare to BDADDR_ANY. > > Yes. If not memset, then garbage value is compared against BDADDR_ANY. since that is not obviously clear, the takeaway from my review should have been that you either describe this properly in the commit message or you add a comment. Regards Marcel