Skip to content

Commit e3c026b

Browse files
committed
PCI/MSI: Remove over-zealous hardware size check in pci_msix_validate_entries()
pci_msix_validate_entries() validates the entries array which is handed in by the caller for a MSI-X interrupt allocation. Aside of consistency failures it also detects a failure when the size of the MSI-X hardware table in the device is smaller than the size of the entries array. That's wrong for the case of range allocations where the caller provides the minimum and the maximum number of vectors to allocate, when the hardware size is greater or equal than the mininum, but smaller than the maximum. Remove the hardware size check completely from that function and just ensure that the entires array up to the maximum size is consistent. The limitation and range checking versus the hardware size happens independently of that afterwards anyway because the entries array is optional. Fixes: 4644d22 ("PCI/MSI: Validate MSI-X contiguous restriction early") Reported-by: David Laight <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/87v8i3sg62.ffs@tglx
1 parent 09a9639 commit e3c026b

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

drivers/pci/msi/msi.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,7 @@ static int msix_capability_init(struct pci_dev *dev, struct msix_entry *entries,
750750
return ret;
751751
}
752752

753-
static bool pci_msix_validate_entries(struct pci_dev *dev, struct msix_entry *entries,
754-
int nvec, int hwsize)
753+
static bool pci_msix_validate_entries(struct pci_dev *dev, struct msix_entry *entries, int nvec)
755754
{
756755
bool nogap;
757756
int i, j;
@@ -762,10 +761,6 @@ static bool pci_msix_validate_entries(struct pci_dev *dev, struct msix_entry *en
762761
nogap = pci_msi_domain_supports(dev, MSI_FLAG_MSIX_CONTIGUOUS, DENY_LEGACY);
763762

764763
for (i = 0; i < nvec; i++) {
765-
/* Entry within hardware limit? */
766-
if (entries[i].entry >= hwsize)
767-
return false;
768-
769764
/* Check for duplicate entries */
770765
for (j = i + 1; j < nvec; j++) {
771766
if (entries[i].entry == entries[j].entry)
@@ -805,7 +800,7 @@ int __pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int
805800
if (hwsize < 0)
806801
return hwsize;
807802

808-
if (!pci_msix_validate_entries(dev, entries, nvec, hwsize))
803+
if (!pci_msix_validate_entries(dev, entries, nvec))
809804
return -EINVAL;
810805

811806
if (hwsize < nvec) {

0 commit comments

Comments
 (0)