drivers/net/usb/aqc111.c:606:34: sparse: sparse: incorrect type in argument 1 (different base types)

From: kernel test robot
Date: Sun Dec 24 2023 - 14:18:44 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 861deac3b092f37b2c5e6871732f3e11486f7082
commit: 361459cd9642631f048719169da9ef14cbf4a932 net: usb: aqc111: Implement RX data path
date: 5 years ago
config: x86_64-randconfig-x001-20230717 (https://download.01.org/0day-ci/archive/20231225/202312250354.xeVTLITE-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231225/202312250354.xeVTLITE-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202312250354.xeVTLITE-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> drivers/net/usb/aqc111.c:606:34: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected restricted __le64 const [usertype] *p @@ got unsigned long long [usertype] * @@
drivers/net/usb/aqc111.c:606:34: sparse: expected restricted __le64 const [usertype] *p
drivers/net/usb/aqc111.c:606:34: sparse: got unsigned long long [usertype] *
>> drivers/net/usb/aqc111.c:629:45: sparse: sparse: incorrect type in argument 1 (different base types) @@ expected restricted __le64 const [usertype] *p @@ got unsigned long long [usertype] *[assigned] pkt_desc_ptr @@
drivers/net/usb/aqc111.c:629:45: sparse: expected restricted __le64 const [usertype] *p
drivers/net/usb/aqc111.c:629:45: sparse: got unsigned long long [usertype] *[assigned] pkt_desc_ptr
drivers/net/usb/aqc111.c:724:22: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned long long [usertype] @@ got restricted __le64 [usertype] @@
drivers/net/usb/aqc111.c:724:22: sparse: expected unsigned long long [usertype]
drivers/net/usb/aqc111.c:724:22: sparse: got restricted __le64 [usertype]
drivers/net/usb/aqc111.c: note: in included file (through include/linux/textsearch.h, include/linux/skbuff.h, include/linux/if_ether.h, ...):
include/linux/slab.h:332:43: sparse: sparse: dubious: x & !y
drivers/net/usb/aqc111.c:20:12: warning: 'aqc111_read_cmd_nopm' defined but not used [-Wunused-function]
20 | static int aqc111_read_cmd_nopm(struct usbnet *dev, u8 cmd, u16 value,
| ^~~~~~~~~~~~~~~~~~~~

vim +606 drivers/net/usb/aqc111.c

585
586 static int aqc111_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
587 {
588 struct sk_buff *new_skb = NULL;
589 u32 pkt_total_offset = 0;
590 u64 *pkt_desc_ptr = NULL;
591 u32 start_of_descs = 0;
592 u32 desc_offset = 0; /*RX Header Offset*/
593 u16 pkt_count = 0;
594 u64 desc_hdr = 0;
595 u32 skb_len = 0;
596
597 if (!skb)
598 goto err;
599
600 if (skb->len == 0)
601 goto err;
602
603 skb_len = skb->len;
604 /* RX Descriptor Header */
605 skb_trim(skb, skb->len - sizeof(desc_hdr));
> 606 desc_hdr = le64_to_cpup((u64 *)skb_tail_pointer(skb));
607
608 /* Check these packets */
609 desc_offset = (desc_hdr & AQ_RX_DH_DESC_OFFSET_MASK) >>
610 AQ_RX_DH_DESC_OFFSET_SHIFT;
611 pkt_count = desc_hdr & AQ_RX_DH_PKT_CNT_MASK;
612 start_of_descs = skb_len - ((pkt_count + 1) * sizeof(desc_hdr));
613
614 /* self check descs position */
615 if (start_of_descs != desc_offset)
616 goto err;
617
618 /* self check desc_offset from header*/
619 if (desc_offset >= skb_len)
620 goto err;
621
622 if (pkt_count == 0)
623 goto err;
624
625 /* Get the first RX packet descriptor */
626 pkt_desc_ptr = (u64 *)(skb->data + desc_offset);
627
628 while (pkt_count--) {
> 629 u64 pkt_desc = le64_to_cpup(pkt_desc_ptr);
630 u32 pkt_len_with_padd = 0;
631 u32 pkt_len = 0;
632
633 pkt_len = (u32)((pkt_desc & AQ_RX_PD_LEN_MASK) >>
634 AQ_RX_PD_LEN_SHIFT);
635 pkt_len_with_padd = ((pkt_len + 7) & 0x7FFF8);
636
637 pkt_total_offset += pkt_len_with_padd;
638 if (pkt_total_offset > desc_offset ||
639 (pkt_count == 0 && pkt_total_offset != desc_offset)) {
640 goto err;
641 }
642
643 if (pkt_desc & AQ_RX_PD_DROP ||
644 !(pkt_desc & AQ_RX_PD_RX_OK) ||
645 pkt_len > (dev->hard_mtu + AQ_RX_HW_PAD)) {
646 skb_pull(skb, pkt_len_with_padd);
647 /* Next RX Packet Descriptor */
648 pkt_desc_ptr++;
649 continue;
650 }
651
652 /* Clone SKB */
653 new_skb = skb_clone(skb, GFP_ATOMIC);
654
655 if (!new_skb)
656 goto err;
657
658 new_skb->len = pkt_len;
659 skb_pull(new_skb, AQ_RX_HW_PAD);
660 skb_set_tail_pointer(new_skb, new_skb->len);
661
662 new_skb->truesize = SKB_TRUESIZE(new_skb->len);
663
664 usbnet_skb_return(dev, new_skb);
665 if (pkt_count == 0)
666 break;
667
668 skb_pull(skb, pkt_len_with_padd);
669
670 /* Next RX Packet Header */
671 pkt_desc_ptr++;
672
673 new_skb = NULL;
674 }
675
676 return 1;
677
678 err:
679 return 0;
680 }
681

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki