From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 347BB39733E; Tue, 21 Jul 2026 22:56:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784674595; cv=none; b=Jx7Fj8gmazbeJ7UFyJdbHDnkJbrCSvDrnHEQkbC0N6Mtrs+T8tA6mHV7Y1bnhR2jJ35SGlQ6nuK9vvpocRDEnKgAyr7cnh1Q05JGwDtlieC2UpRRkpk7QS1+LZE7zOJEIQsNCW37S633Bia5KpC7I+W6/lccfRX1IJCYjRxoQcs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784674595; c=relaxed/simple; bh=qjLhZPMNPxcdwt1mhtj95AvlRpZjJ7wFnuZwakwG/SQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r231+PH8t+Gw20+8/JAdpxIfJF/cMdZlol7PpVPg7KcvWlWIqeMpyf6iEV2mYla+3P6quHpZRv0GOvg0nwUN2zImPedsaR1T8vn/5jmPCpA6+f6mWnDvoY04CYwOTlYV/nih2uq1fCC8GJss51TjqboUrS6d/9WnrJTUdgiz/Kw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uuOoa5oQ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="uuOoa5oQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BA0D1F000E9; Tue, 21 Jul 2026 22:56:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784674594; bh=IffvZ3TBXCADAoQBksO9VzIre9itEaD26xrpNdDNew4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uuOoa5oQBPqmjZ2256WIv5kZt3UJUHgqoVBdMIDycWvA7i88ROtz6MGWp2Z0T8mQ9 7CtM7AYakZnp3pTBr4LqIP8QF1xq79xIYe7lHyX4T1EOeMwkzc2HfUQqTxug7QaH2c FVxawBmxR7PTu39jAQYd136cGfBV2G7+2nT8Wy4U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Mahesh Vaidya , Manivannan Sadhasivam , "Subhransu S. Prusty" , Sasha Levin Subject: [PATCH 5.10 601/699] PCI: altera: Fix resource leaks on probe failure Date: Tue, 21 Jul 2026 17:26:00 +0200 Message-ID: <20260721152409.286481045@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152355.667394603@linuxfoundation.org> References: <20260721152355.667394603@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mahesh Vaidya [ 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. Fixes: c63aed7334c2 ("PCI: altera: Use pci_host_probe() to register host") Signed-off-by: Mahesh Vaidya [mani: commit log] Signed-off-by: Manivannan Sadhasivam Reviewed-by: Subhransu S. Prusty Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20260430204330.3121003-3-mahesh.vaidya@altera.com Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/pci/controller/pcie-altera.c | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) --- a/drivers/pci/controller/pcie-altera.c +++ b/drivers/pci/controller/pcie-altera.c @@ -685,8 +685,18 @@ static int altera_pcie_init_irq_domain(s 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); } @@ -711,7 +721,6 @@ static int altera_pcie_parse_dt(struct a if (pcie->irq < 0) return pcie->irq; - irq_set_chained_handler_and_data(pcie->irq, altera_pcie_isr, pcie); return 0; } @@ -796,6 +805,12 @@ static int altera_pcie_probe(struct plat 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 */ @@ -806,7 +821,16 @@ static int altera_pcie_probe(struct plat 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)