[meghadey-crypto:d_msix 1/1] drivers/pci/msi.c:1040 __pci_enable_msix() warn: unsigned 'dev->msix_vec_cnt' is never less than zero.

kernel test robot
2021-08-31T00:26:59Z

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

tree: https://github.com/meghadey/crypto d_msix
head: 00c6841830531fd32a943ceb9838af5a95a00524
commit: 00c6841830531fd32a943ceb9838af5a95a00524 [1/1] PCI/MSI: Dynamic allocation of MSI-X vectors
config: s390-randconfig-m031-20210830 (attached as .config)
compiler: s390-linux-gcc (GCC) 11.2.0

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

smatch warnings:
drivers/pci/msi.c:1040 __pci_enable_msix() warn: unsigned 'dev->msix_vec_cnt' is never less than zero.

vim +1040 drivers/pci/msi.c

1029
1030 static int __pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries,
1031 int nvec, struct irq_affinity *affd, int flags)
1032 {
1033 int i, j, ret;
1034
1035 if (!pci_msi_supported(dev, nvec) || dev->current_state != PCI_D0)
1036 return -EINVAL;
1037
1038 dev->msix_vec_cnt = pci_msix_vec_count(dev);
1039 if (!dev->msix_enabled) {
> 1040 if (dev->msix_vec_cnt < 0)
1041 return dev->msix_vec_cnt;
1042 dev->msix_map = kcalloc(BITS_TO_LONGS(dev->msix_vec_cnt), sizeof(long), GFP_KERNEL);
1043 if (!dev->msix_map)
1044 return -ENOMEM;
1045 }
1046
1047 if (nvec > (dev->msix_vec_cnt - dev->msix_alloc_cnt) && !(flags & PCI_IRQ_VIRTUAL))
1048 return dev->msix_vec_cnt - dev->msix_alloc_cnt;
1049
1050 if (entries) {
1051 /* Check for any invalid entries */
1052 for (i = 0; i < nvec; i++) {
1053 if (entries[i].entry >= dev->msix_vec_cnt)
1054 return -EINVAL; /* invalid entry */
1055 for (j = i + 1; j < nvec; j++) {
1056 if (entries[i].entry == entries[j].entry)
1057 return -EINVAL; /* duplicate entry */
1058 }
1059 }
1060 }
1061
1062 /* Check whether driver already requested for MSI IRQ */
1063 if (dev->msi_enabled) {
1064 pci_info(dev, "can't enable MSI-X (MSI IRQ already assigned)\n");
1065 return -EINVAL;
1066 }
1067
1068 if (!dev->msix_enabled) {
1069 ret = msix_setup_table(dev);
1070 if (ret)
1071 return ret;
1072 }
1073
1074 return msix_setup_irqs(dev, entries, nvec, affd);
1075 }
1076

---
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: 36764 bytes --]