FAILED: patch "[PATCH] PCI: altera: Fix resource leaks on probe failure" failed to apply to 5.10-stable tree
Subsystems (4)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 7a94138caeb27f3c49c1dbd93bf422098925bb28
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026071330-snugly-map-ad62@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 7a94138caeb27f3c49c1dbd93bf422098925bb28 Mon Sep 17 00:00:00 2001
From: Mahesh Vaidya <[email protected]>
Date: Thu, 30 Apr 2026 13:43:30 -0700
Subject: [PATCH] PCI: altera: Fix resource leaks on probe failure
The chained IRQ handler is set during probe, but is only removed during the driver remove(). If pci_host_probe() fails, the handler and INTx IRQ domain remain set even though the devm-managed host bridge storage containing struct altera_pcie will be released, leaving the handler with a stale data pointer.
Interrupts are also enabled before pci_host_probe() is called. If probe fails after that point, the controller interrupt source should be disabled before the chained handler and INTx domain are removed.
So set the chained handler only after the INTx domain has been created. Disable controller interrupts during IRQ teardown, and tear the IRQ setup down if pci_host_probe() fails.
drivers/pci/controller/pcie-altera.c +33 -2
@@ -864,8 +864,23 @@ static int altera_pcie_init_irq_domain(struct altera_pcie *pcie)return 0 ; } +static void altera_pcie_disable_irq (struct altera_pcie *pcie) +{ +if (pcie->pcie_data->version ==ALTERA_PCIE_V1 || + pcie->pcie_data->version ==ALTERA_PCIE_V2 ) { +/* Disable all P2A interrupts */ +cra_writel (pcie,0 ,P2A_INT_ENABLE ); + }else if (pcie->pcie_data->version ==ALTERA_PCIE_V3 ) { +/* Disable port-level interrupts (CFG_AER, etc.) */ +writel (0 , pcie->hip_base + + pcie->pcie_data->port_conf_offset + + pcie->pcie_data->port_irq_enable_offset); + } +} +static void altera_pcie_irq_teardown (struct altera_pcie *pcie) { +altera_pcie_disable_irq (pcie);irq_set_chained_handler_and_data (pcie->irq,NULL ,NULL );irq_domain_remove (pcie->irq_domain); }
@@ -890,7 +905,6 @@ static int altera_pcie_parse_dt(struct altera_pcie *pcie)if (pcie->irq <0 )return pcie->irq; -irq_set_chained_handler_and_data (pcie->irq, pcie->pcie_data->ops->rp_isr, pcie);return 0 ; }
@@ -1019,6 +1033,14 @@ static int altera_pcie_probe(struct platform_device *pdev)return ret; } +/* +* The chained handler uses pcie->irq_domain, so set it only after the +* INTx domain has been created. +*/ +irq_set_chained_handler_and_data (pcie->irq, + pcie->pcie_data->ops->rp_isr, + pcie); +if (pcie->pcie_data->version ==ALTERA_PCIE_V1 || pcie->pcie_data->version ==ALTERA_PCIE_V2 ) {/* clear all interrupts */
@@ -1036,7 +1058,16 @@ static int altera_pcie_probe(struct platform_device *pdev) bridge->busnr = pcie->root_bus_nr; bridge->ops = &altera_pcie_ops; -return pci_host_probe (bridge); + ret =pci_host_probe (bridge); +if (ret) + goto err_teardown_irq; + +return 0 ; + +err_teardown_irq: +altera_pcie_irq_teardown (pcie); + +return ret; }static void altera_pcie_remove (struct platform_device *pdev)
Sasha Levin
maintainerPATCH 1/1 PCI: altera: Fix resource leaks on probe failure
From: Mahesh Vaidya <[email protected]>
[ Upstream commit 7a94138caeb27f3c49c1dbd93bf422098925bb28 ]
The chained IRQ handler is set during probe, but is only removed during the driver remove(). If pci_host_probe() fails, the handler and INTx IRQ domain remain set even though the devm-managed host bridge storage containing struct altera_pcie will be released, leaving the handler with a stale data pointer.
Interrupts are also enabled before pci_host_probe() is called. If probe fails after that point, the controller interrupt source should be disabled before the chained handler and INTx domain are removed.
So set the chained handler only after the INTx domain has been created. Disable controller interrupts during IRQ teardown, and tear the IRQ setup down if pci_host_probe() fails.
--- drivers/pci/controller/pcie-altera.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-)
drivers/pci/controller/pcie-altera.c +26 -2
@@ -685,8 +685,18 @@ static int altera_pcie_init_irq_domain(struct altera_pcie *pcie)return 0 ; } +static void altera_pcie_disable_irq (struct altera_pcie *pcie) +{ +if (pcie->pcie_data->version ==ALTERA_PCIE_V1 || + pcie->pcie_data->version ==ALTERA_PCIE_V2 ) { +/* Disable all P2A interrupts */ +cra_writel (pcie,0 ,P2A_INT_ENABLE ); + } +} +static void altera_pcie_irq_teardown (struct altera_pcie *pcie) { +altera_pcie_disable_irq (pcie);irq_set_chained_handler_and_data (pcie->irq,NULL ,NULL );irq_domain_remove (pcie->irq_domain);irq_dispose_mapping (pcie->irq);
@@ -712,7 +722,6 @@ static int altera_pcie_parse_dt(struct altera_pcie *pcie)if (pcie->irq <0 )return pcie->irq; -irq_set_chained_handler_and_data (pcie->irq, altera_pcie_isr, pcie);return 0 ; }
@@ -797,6 +806,12 @@ static int altera_pcie_probe(struct platform_device *pdev)return ret; } +/* +* The chained handler uses pcie->irq_domain, so set it only after the +* INTx domain has been created. +*/ +irq_set_chained_handler_and_data (pcie->irq, altera_pcie_isr, pcie); +/* clear all interrupts */ cra_writel (pcie,P2A_INT_STS_ALL ,P2A_INT_STATUS );/* enable all interrupts */
@@ -807,7 +822,16 @@ static int altera_pcie_probe(struct platform_device *pdev) bridge->busnr = pcie->root_bus_nr; bridge->ops = &altera_pcie_ops; -return pci_host_probe (bridge); + ret =pci_host_probe (bridge); +if (ret) + goto err_teardown_irq; + +return 0 ; + +err_teardown_irq: +altera_pcie_irq_teardown (pcie); + +return ret; }static int altera_pcie_remove (struct platform_device *pdev)
Signature · 1 line
2.53.0