drivers/bluetooth/btintel.c:441:33: sparse: sparse: cast to restricted __le32

From: kernel test robot
Date: Sun Nov 14 2021 - 00:52:17 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: c8c109546a19613d323a319d0c921cb1f317e629
commit: 66500bbc7d6b4915cae86d64c72591cb70698c9d Bluetooth: btintel: Fix endianness issue for TLV version information
date: 11 months ago
config: riscv-randconfig-s031-20211109 (attached as .config)
compiler: riscv64-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://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=66500bbc7d6b4915cae86d64c72591cb70698c9d
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout 66500bbc7d6b4915cae86d64c72591cb70698c9d
# 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=riscv SHELL=/bin/bash block/ drivers/bluetooth/ drivers/hid/ drivers/hwmon/ drivers/i2c/busses/ drivers/message/fusion/ drivers/net/ethernet/ drivers/net/wireless/intel/iwlwifi/ drivers/pci/ drivers/remoteproc/ drivers/rtc/ drivers/staging/rts5208/ drivers/staging/vc04_services/ drivers/tty/serial/ drivers/vdpa/ drivers/video/fbdev/ net/qrtr/ net/sched/

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


sparse warnings: (new ones prefixed by >>)
>> drivers/bluetooth/btintel.c:441:33: sparse: sparse: cast to restricted __le32
drivers/bluetooth/btintel.c:445:33: sparse: sparse: cast to restricted __le32
drivers/bluetooth/btintel.c:449:33: sparse: sparse: cast to restricted __le32
drivers/bluetooth/btintel.c:453:33: sparse: sparse: cast to restricted __le32
>> drivers/bluetooth/btintel.c:457:33: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btintel.c:464:33: sparse: sparse: cast to restricted __le16
drivers/bluetooth/btintel.c:471:33: sparse: sparse: cast to restricted __le32

vim +441 drivers/bluetooth/btintel.c

403
404 int btintel_read_version_tlv(struct hci_dev *hdev, struct intel_version_tlv *version)
405 {
406 struct sk_buff *skb;
407 const u8 param[1] = { 0xFF };
408
409 if (!version)
410 return -EINVAL;
411
412 skb = __hci_cmd_sync(hdev, 0xfc05, 1, param, HCI_CMD_TIMEOUT);
413 if (IS_ERR(skb)) {
414 bt_dev_err(hdev, "Reading Intel version information failed (%ld)",
415 PTR_ERR(skb));
416 return PTR_ERR(skb);
417 }
418
419 if (skb->data[0]) {
420 bt_dev_err(hdev, "Intel Read Version command failed (%02x)",
421 skb->data[0]);
422 kfree_skb(skb);
423 return -EIO;
424 }
425
426 /* Consume Command Complete Status field */
427 skb_pull(skb, 1);
428
429 /* Event parameters contatin multiple TLVs. Read each of them
430 * and only keep the required data. Also, it use existing legacy
431 * version field like hw_platform, hw_variant, and fw_variant
432 * to keep the existing setup flow
433 */
434 while (skb->len) {
435 struct intel_tlv *tlv;
436
437 tlv = (struct intel_tlv *)skb->data;
438 switch (tlv->type) {
439 case INTEL_TLV_CNVI_TOP:
440 version->cnvi_top =
> 441 __le32_to_cpu(get_unaligned_le32(tlv->val));
442 break;
443 case INTEL_TLV_CNVR_TOP:
444 version->cnvr_top =
445 __le32_to_cpu(get_unaligned_le32(tlv->val));
446 break;
447 case INTEL_TLV_CNVI_BT:
448 version->cnvi_bt =
449 __le32_to_cpu(get_unaligned_le32(tlv->val));
450 break;
451 case INTEL_TLV_CNVR_BT:
452 version->cnvr_bt =
453 __le32_to_cpu(get_unaligned_le32(tlv->val));
454 break;
455 case INTEL_TLV_DEV_REV_ID:
456 version->dev_rev_id =
> 457 __le16_to_cpu(get_unaligned_le16(tlv->val));
458 break;
459 case INTEL_TLV_IMAGE_TYPE:
460 version->img_type = tlv->val[0];
461 break;
462 case INTEL_TLV_TIME_STAMP:
463 version->timestamp =
464 __le16_to_cpu(get_unaligned_le16(tlv->val));
465 break;
466 case INTEL_TLV_BUILD_TYPE:
467 version->build_type = tlv->val[0];
468 break;
469 case INTEL_TLV_BUILD_NUM:
470 version->build_num =
471 __le32_to_cpu(get_unaligned_le32(tlv->val));
472 break;
473 case INTEL_TLV_SECURE_BOOT:
474 version->secure_boot = tlv->val[0];
475 break;
476 case INTEL_TLV_OTP_LOCK:
477 version->otp_lock = tlv->val[0];
478 break;
479 case INTEL_TLV_API_LOCK:
480 version->api_lock = tlv->val[0];
481 break;
482 case INTEL_TLV_DEBUG_LOCK:
483 version->debug_lock = tlv->val[0];
484 break;
485 case INTEL_TLV_MIN_FW:
486 version->min_fw_build_nn = tlv->val[0];
487 version->min_fw_build_cw = tlv->val[1];
488 version->min_fw_build_yy = tlv->val[2];
489 break;
490 case INTEL_TLV_LIMITED_CCE:
491 version->limited_cce = tlv->val[0];
492 break;
493 case INTEL_TLV_SBE_TYPE:
494 version->sbe_type = tlv->val[0];
495 break;
496 case INTEL_TLV_OTP_BDADDR:
497 memcpy(&version->otp_bd_addr, tlv->val, tlv->len);
498 break;
499 default:
500 /* Ignore rest of information */
501 break;
502 }
503 /* consume the current tlv and move to next*/
504 skb_pull(skb, tlv->len + sizeof(*tlv));
505 }
506
507 kfree_skb(skb);
508 return 0;
509 }
510 EXPORT_SYMBOL_GPL(btintel_read_version_tlv);
511

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

Attachment: .config.gz
Description: application/gzip