vdpa/octeon_ep: enable support for multiple interrupts per device
Hello Shijith Thotton,
Commit 26f8ce06af64 ("vdpa/octeon_ep: enable support for multiple interrupts per device") from Jan 3, 2025 (linux-next), leads to the following issue:
drivers/vdpa/octeon_ep/octep_vdpa_main.c:114: ret = pci_alloc_irq_vectors(pdev, 1, oct_hw->nb_irqs, PCI_IRQ_MSIX);
This assumes that pci_alloc_irq_vectors() allocates the maximum.
drivers/vdpa/octeon_ep/octep_vdpa_main.c
104
105 static int octep_request_irqs(struct octep_hw *oct_hw)
106 {
107 struct pci_dev *pdev = oct_hw->pdev;
108 int ret, irq, idx;
109
110 oct_hw->irqs = devm_kcalloc(&pdev->dev, oct_hw->nb_irqs, sizeof(int), GFP_KERNEL);
111 if (!oct_hw->irqs)
112 return -ENOMEM;
113
--> 114 ret = pci_alloc_irq_vectors(pdev, 1, oct_hw->nb_irqs, PCI_IRQ_MSIX);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^The pci_alloc_irq_vectors() takes a range between 1 and oct_hw->nb_irqs. If it can't allocate the minimum (1) it will return a negative error code, otherwise it will return a number between 1 and oct_hw->nb_irqs inclusive.
115 if (ret < 0) {
116 dev_err(&pdev->dev, "Failed to alloc msix vector");
117 return ret;
118 }
119
120 for (idx = 0; idx < oct_hw->nb_irqs; idx++) {
^^^^^^^^^^^^^^^This should be "ret". We can't assume it allocated all the irq vectors.
121 irq = pci_irq_vector(pdev, idx);
122 ret = devm_request_irq(&pdev->dev, irq, octep_vdpa_intr_handler, 0,
123 dev_name(&pdev->dev), oct_hw);
124 if (ret) {regards,
dan carpenter