0005-Bluetooth-btintel-Fix-bdaddress-comparison-with-garb.patch 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. From cbc793d1444eafb47b1cc0062c605b37fe79736f Mon Sep 17 00:00:00 2001
  2. From: Kiran K <kiran.k@intel.com>
  3. Date: Wed, 13 Oct 2021 13:35:11 +0530
  4. Subject: [PATCH 5/6] Bluetooth: btintel: Fix bdaddress comparison with garbage
  5. value
  6. Intel Read Verision(TLV) data is parsed into a local structure variable
  7. and it contains a field for bd address. Bd address is returned only in
  8. bootloader mode and hence bd address in TLV structure needs to be validated
  9. only if controller is present in boot loader mode.
  10. Signed-off-by: Kiran K <kiran.k@intel.com>
  11. Reviewed-by: Tedd Ho-Jeong An <tedd.an@intel.com>
  12. ---
  13. drivers/bluetooth/btintel.c | 22 ++++++++++++++--------
  14. 1 file changed, 14 insertions(+), 8 deletions(-)
  15. diff --git a/drivers/bluetooth/btintel.c b/drivers/bluetooth/btintel.c
  16. index f1705b46fc88..b9055a3e61ed 100644
  17. --- a/drivers/bluetooth/btintel.c
  18. +++ b/drivers/bluetooth/btintel.c
  19. @@ -2006,14 +2006,16 @@ static int btintel_prepare_fw_download_tlv(struct hci_dev *hdev,
  20. if (ver->img_type == 0x03) {
  21. btintel_clear_flag(hdev, INTEL_BOOTLOADER);
  22. btintel_check_bdaddr(hdev);
  23. - }
  24. -
  25. - /* If the OTP has no valid Bluetooth device address, then there will
  26. - * also be no valid address for the operational firmware.
  27. - */
  28. - if (!bacmp(&ver->otp_bd_addr, BDADDR_ANY)) {
  29. - bt_dev_info(hdev, "No device address configured");
  30. - set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
  31. + } else {
  32. + /*
  33. + * Check for valid bd address in boot loader mode. Device
  34. + * will be marked as unconfigured if empty bd address is
  35. + * found.
  36. + */
  37. + if (!bacmp(&ver->otp_bd_addr, BDADDR_ANY)) {
  38. + bt_dev_info(hdev, "No device address configured");
  39. + set_bit(HCI_QUIRK_INVALID_BDADDR, &hdev->quirks);
  40. + }
  41. }
  42. btintel_get_fw_name_tlv(ver, fwname, sizeof(fwname), "sfi");
  43. @@ -2303,6 +2305,10 @@ static int btintel_setup_combined(struct hci_dev *hdev)
  44. goto exit_error;
  45. }
  46. + /* memset ver_tlv to start with clean state as few fields are exclusive
  47. + * to bootloader mode and are not populated in operational mode
  48. + */
  49. + memset(&ver_tlv, 0, sizeof(ver_tlv));
  50. /* For TLV type device, parse the tlv data */
  51. err = btintel_parse_version_tlv(hdev, &ver_tlv, skb);
  52. if (err) {
  53. --
  54. 2.34.1