Re: [PATCH v2] bluetooth: Add support to handle MSFT Monitor Device event

kernel test robot
2021-10-14T04:03:00Z

[-- Attachment #1: Type: text/plain, Size: 6512 bytes --]

Hi Manish,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on bluetooth-next/master]
[also build test WARNING on next-20211013]
[cannot apply to bluetooth/master v5.15-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url: https://github.com/0day-ci/linux/commits/Manish-Mandlik/bluetooth-Add-support-to-handle-MSFT-Monitor-Device-event/20211013-211504
base: https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
config: sparc64-randconfig-s032-20211013 (attached as .config)
compiler: sparc64-linux-gcc (GCC) 11.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/0day-ci/linux/commit/8c24f97d82e241c5605046401a106ace240d1a5d
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Manish-Mandlik/bluetooth-Add-support-to-handle-MSFT-Monitor-Device-event/20211013-211504
git checkout 8c24f97d82e241c5605046401a106ace240d1a5d
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=sparc64 SHELL=/bin/bash net/bluetooth/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

sparse warnings: (new ones prefixed by >>)
net/bluetooth/mgmt.c:3647:29: sparse: sparse: restricted __le16 degrades to integer
net/bluetooth/mgmt.c:4352:9: sparse: sparse: cast to restricted __le32
net/bluetooth/mgmt.c:4352:9: sparse: sparse: cast to restricted __le32
net/bluetooth/mgmt.c:4352:9: sparse: sparse: cast to restricted __le32
net/bluetooth/mgmt.c:4352:9: sparse: sparse: cast to restricted __le32
net/bluetooth/mgmt.c:4352:9: sparse: sparse: cast to restricted __le32
net/bluetooth/mgmt.c:4352:9: sparse: sparse: cast to restricted __le32
>> net/bluetooth/mgmt.c:9712:43: sparse: sparse: invalid assignment: |=
>> net/bluetooth/mgmt.c:9712:43: sparse: left side has type restricted __le32
>> net/bluetooth/mgmt.c:9712:43: sparse: right side has type int

vim +9712 net/bluetooth/mgmt.c

9620
9621 void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
9622 u8 addr_type, u8 *dev_class, s8 rssi, u32 flags,
9623 u8 *eir, u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len)
9624 {
9625 char buf[512];
9626 struct monitored_device *dev, *tmp_dev;
9627 struct mgmt_ev_device_found *ev = (void *)buf;
9628 size_t ev_size;
9629 bool monitored = false;
9630
9631 /* Don't send events for a non-kernel initiated discovery. With
9632 * LE one exception is if we have pend_le_reports > 0 in which
9633 * case we're doing passive scanning and want these events.
9634 */
9635 if (!hci_discovery_active(hdev)) {
9636 if (link_type == ACL_LINK)
9637 return;
9638 if (link_type == LE_LINK &&
9639 list_empty(&hdev->pend_le_reports) &&
9640 !hci_is_adv_monitoring(hdev)) {
9641 return;
9642 }
9643 }
9644
9645 if (hdev->discovery.result_filtering) {
9646 /* We are using service discovery */
9647 if (!is_filter_match(hdev, rssi, eir, eir_len, scan_rsp,
9648 scan_rsp_len))
9649 return;
9650 }
9651
9652 if (hdev->discovery.limited) {
9653 /* Check for limited discoverable bit */
9654 if (dev_class) {
9655 if (!(dev_class[1] & 0x20))
9656 return;
9657 } else {
9658 u8 *flags = eir_get_data(eir, eir_len, EIR_FLAGS, NULL);
9659 if (!flags || !(flags[0] & LE_AD_LIMITED))
9660 return;
9661 }
9662 }
9663
9664 /* Make sure that the buffer is big enough. The 5 extra bytes
9665 * are for the potential CoD field.
9666 */
9667 if (sizeof(*ev) + eir_len + scan_rsp_len + 5 > sizeof(buf))
9668 return;
9669
9670 memset(buf, 0, sizeof(buf));
9671
9672 /* In case of device discovery with BR/EDR devices (pre 1.2), the
9673 * RSSI value was reported as 0 when not available. This behavior
9674 * is kept when using device discovery. This is required for full
9675 * backwards compatibility with the API.
9676 *
9677 * However when using service discovery, the value 127 will be
9678 * returned when the RSSI is not available.
9679 */
9680 if (rssi == HCI_RSSI_INVALID && !hdev->discovery.report_invalid_rssi &&
9681 link_type == ACL_LINK)
9682 rssi = 0;
9683
9684 bacpy(&ev->addr.bdaddr, bdaddr);
9685 ev->addr.type = link_to_bdaddr(link_type, addr_type);
9686 ev->rssi = rssi;
9687 ev->flags = cpu_to_le32(flags);
9688
9689 if (eir_len > 0)
9690 /* Copy EIR or advertising data into event */
9691 memcpy(ev->eir, eir, eir_len);
9692
9693 if (dev_class && !eir_get_data(ev->eir, eir_len, EIR_CLASS_OF_DEV,
9694 NULL))
9695 eir_len = eir_append_data(ev->eir, eir_len, EIR_CLASS_OF_DEV,
9696 dev_class, 3);
9697
9698 if (scan_rsp_len > 0)
9699 /* Append scan response data to event */
9700 memcpy(ev->eir + eir_len, scan_rsp, scan_rsp_len);
9701
9702 ev->eir_len = cpu_to_le16(eir_len + scan_rsp_len);
9703 ev_size = sizeof(*ev) + eir_len + scan_rsp_len;
9704
9705 if (!list_empty(&hdev->monitored_devices)) {
9706 /* An advertisement could match multiple advertisement monitors.
9707 * Send the Device Found event once for all matched monitors.
9708 */
9709 list_for_each_entry_safe(dev, tmp_dev, &hdev->monitored_devices,
9710 list) {
9711 if (!bacmp(&dev->bdaddr, &ev->addr.bdaddr)) {
> 9712 ev->flags |= MGMT_DEV_FOUND_MONITORING;
9713 ev->monitor_handle = cpu_to_le16(dev->handle);
9714
9715 list_del(&dev->list);
9716 kfree(dev);
9717
9718 mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev,
9719 ev_size, NULL);
9720 monitored = true;
9721 }
9722 }
9723 }
9724
9725 if (!monitored)
9726 mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL);
9727 }
9728

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35691 bytes --]