[PATCH] misc: microchip: pci1xxxx: fix IRQ vector leak in gp_aux_bus_probe()

Guangshuo Li posted 1 patch 2 months, 1 week ago
There is a newer version of this series
drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
[PATCH] misc: microchip: pci1xxxx: fix IRQ vector leak in gp_aux_bus_probe()
Posted by Guangshuo Li 2 months, 1 week ago
gp_aux_bus_probe() allocates IRQ vectors with pci_alloc_irq_vectors()
before initializing and adding the second auxiliary device.

When pci_irq_vector(), auxiliary_device_init() or auxiliary_device_add()
for the second auxiliary device fails, the function unwinds the auxiliary
devices and ida allocations, but leaves the allocated IRQ vectors behind.

Add a dedicated error path to call pci_free_irq_vectors() after IRQ
vectors have been allocated successfully.

Fixes: 393fc2f5948f ("misc: microchip: pci1xxxx: load auxiliary bus driver for the PIO function in the multi-function endpoint of pci1xxxx device.")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
index 34c9be437432..5e1f99a35100 100644
--- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
+++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
@@ -93,14 +93,14 @@ static int gp_aux_bus_probe(struct pci_dev *pdev, const struct pci_device_id *id
 
 	retval = pci_irq_vector(pdev, 0);
 	if (retval < 0)
-		goto err_aux_dev_init_1;
+		goto err_irq_vectors;
 
 	pdev->irq = retval;
 	aux_bus->aux_device_wrapper[1]->gp_aux_data.irq_num = pdev->irq;
 
 	retval = auxiliary_device_init(&aux_bus->aux_device_wrapper[1]->aux_dev);
 	if (retval < 0)
-		goto err_aux_dev_init_1;
+		goto err_irq_vectors;
 
 	retval = auxiliary_device_add(&aux_bus->aux_device_wrapper[1]->aux_dev);
 	if (retval)
@@ -113,6 +113,9 @@ static int gp_aux_bus_probe(struct pci_dev *pdev, const struct pci_device_id *id
 
 err_aux_dev_add_1:
 	auxiliary_device_uninit(&aux_bus->aux_device_wrapper[1]->aux_dev);
+
+err_irq_vectors:
+	pci_free_irq_vectors(pdev);
 	goto err_aux_dev_add_0;
 
 err_aux_dev_init_1:
-- 
2.43.0
Re: [PATCH] misc: microchip: pci1xxxx: fix IRQ vector leak in gp_aux_bus_probe()
Posted by Guangshuo Li 2 months ago
Hi,

On Sun, 12 Apr 2026 at 21:34, Guangshuo Li <lgs201920130244@gmail.com> wrote:
>
> gp_aux_bus_probe() allocates IRQ vectors with pci_alloc_irq_vectors()
> before initializing and adding the second auxiliary device.
>
> When pci_irq_vector(), auxiliary_device_init() or auxiliary_device_add()
> for the second auxiliary device fails, the function unwinds the auxiliary
> devices and ida allocations, but leaves the allocated IRQ vectors behind.
>
> Add a dedicated error path to call pci_free_irq_vectors() after IRQ
> vectors have been allocated successfully.
>
> Fixes: 393fc2f5948f ("misc: microchip: pci1xxxx: load auxiliary bus driver for the PIO function in the multi-function endpoint of pci1xxxx device.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
>  drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
> index 34c9be437432..5e1f99a35100 100644
> --- a/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
> +++ b/drivers/misc/mchp_pci1xxxx/mchp_pci1xxxx_gp.c
> @@ -93,14 +93,14 @@ static int gp_aux_bus_probe(struct pci_dev *pdev, const struct pci_device_id *id
>
>         retval = pci_irq_vector(pdev, 0);
>         if (retval < 0)
> -               goto err_aux_dev_init_1;
> +               goto err_irq_vectors;
>
>         pdev->irq = retval;
>         aux_bus->aux_device_wrapper[1]->gp_aux_data.irq_num = pdev->irq;
>
>         retval = auxiliary_device_init(&aux_bus->aux_device_wrapper[1]->aux_dev);
>         if (retval < 0)
> -               goto err_aux_dev_init_1;
> +               goto err_irq_vectors;
>
>         retval = auxiliary_device_add(&aux_bus->aux_device_wrapper[1]->aux_dev);
>         if (retval)
> @@ -113,6 +113,9 @@ static int gp_aux_bus_probe(struct pci_dev *pdev, const struct pci_device_id *id
>
>  err_aux_dev_add_1:
>         auxiliary_device_uninit(&aux_bus->aux_device_wrapper[1]->aux_dev);
> +
> +err_irq_vectors:
> +       pci_free_irq_vectors(pdev);
>         goto err_aux_dev_add_0;
>
>  err_aux_dev_init_1:
> --
> 2.43.0
>

I re-checked this issue on our side and found that my previous
analysis was incorrect. This patch is therefore not needed.

I'll drop this patch.

Sorry for the noise, and thanks.

Guangshuo