2021-10-13 08:01:14

by Kiran K

[permalink] [raw]
Subject: [PATCH v2] Bluetooth: btintel: Fix bdaddress comparison with garbage value

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 <[email protected]>
Reviewed-by: Tedd Ho-Jeong An <[email protected]>
---

Notes:
changes in v2:
- Add comment for memsetting ver_tlv

drivers/bluetooth/btintel.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c
index 9359bff47296..8f9109b40961 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,10 @@ static int btintel_setup_combined(struct hci_dev *hdev)
goto exit_error;
}

+ /* memset ver_tlv to start with clean state as few fields are exclusive
+ * to bootloader mode and are not populated in operational mode
+ */
+ memset(&ver_tlv, 0, sizeof(ver_tlv));
/* For TLV type device, parse the tlv data */
err = btintel_parse_version_tlv(hdev, &ver_tlv, skb);
if (err) {
--
2.17.1


2021-10-13 09:13:03

by bluez.test.bot

[permalink] [raw]
Subject: RE: [v2] Bluetooth: btintel: Fix bdaddress comparison with garbage value

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=562455

---Test result---

Test Summary:
CheckPatch PASS 1.89 seconds
GitLint PASS 0.93 seconds
BuildKernel PASS 543.17 seconds
TestRunner: Setup PASS 405.31 seconds
TestRunner: l2cap-tester PASS 9.27 seconds
TestRunner: bnep-tester PASS 4.96 seconds
TestRunner: mgmt-tester PASS 85.41 seconds
TestRunner: rfcomm-tester PASS 5.99 seconds
TestRunner: sco-tester PASS 6.26 seconds
TestRunner: smp-tester PASS 6.01 seconds
TestRunner: userchan-tester PASS 5.24 seconds



---
Regards,
Linux Bluetooth


Attachments:
l2cap-tester.log (43.32 kB)
bnep-tester.log (3.48 kB)
mgmt-tester.log (630.87 kB)
rfcomm-tester.log (11.41 kB)
sco-tester.log (13.60 kB)
smp-tester.log (11.55 kB)
userchan-tester.log (6.22 kB)
Download all attachments

2021-10-13 12:32:18

by Marcel Holtmann

[permalink] [raw]
Subject: Re: [PATCH v2] Bluetooth: btintel: Fix bdaddress comparison with garbage value

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 <[email protected]>
> Reviewed-by: Tedd Ho-Jeong An <[email protected]>
> ---
>
> Notes:
> changes in v2:
> - Add comment for memsetting ver_tlv
>
> drivers/bluetooth/btintel.c | 22 ++++++++++++++--------
> 1 file changed, 14 insertions(+), 8 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel