From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.107 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796290192; b=ZDPre5gRnklhwuYGPwiG+Jk+KGqf98ZikCiW28RcNwB4g/BF7UQ6PhuLaVbNyRHgsidj 9uVmwdGn8R7Z9oXI02vs+/5DdPa/I6yuu2Pt/h5RgqYnboY/2H7veBxWP3lA6m+MfRqT8 0rOT9Z1jlUIyTGMw5NEYhIMa7dYqVeJDsPoPTk8TojTItnDjvwJlWwhpW+LvUq8V6wj66 JAMnZbPT/w2/eM0ta5MTDXdfm4/gwA3qxNjL+XO0XEdgRlbSY2tXzFzkX3ZIF1DZ5TNxK zsQcrfudKoorOVQvSn154zf541Sq313c7hyErpi6pVo17tsi6DFMpUaA4Maec1n4GZQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796290192; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:Date:Subject:MIME-Version: Content-Type:Content-Transfer-Encoding:Message-Id:References: In-Reply-To:To:Cc:X-Mailer; bh=438rndoiXBxTOuMD2g2N5rkzmqpq5RwXRSxHm2I8S1M=; b=WnhkbzioMppA04Dtz9kL9I1bb049JldslCmnpel52PNKr2WACeAnCY+3C50dmtyiH2h/ m0MWGU3JZ5/3xmjKG8fEZp5RLC4kuMgqrEq6rIK8gzgu1RK1Tgi4y49eUd8+gjwwCDeMn 9atEb1sSge4lQbh4ssyJ7sNLlCOVKWCErpIRDb2tGU/+nKoZJOizHzzB78PLcbdQ8PBvz TZDRhcLaWO0pW/pzLyjGVd+uaJ23hCKvEB/MUqgqH4roRULQp2+BHabHA4GuaWhdXayL/ HoJXchVzYksbqCg7EEWhePmP0MCphPhAC+eb7gIaLKPMu6gKv/7uC+zzmf3m7u7yaNw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=OVcSlpML; arc=none smtp.remote-ip=91.218.175.107 Received: from mta0.migadu.com (out-107.mta0.migadu.com [91.218.175.107]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D164D606A32F for ; Thu, 3 Dec 2026 09:29:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org D164D606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=OVcSlpML X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=8JQTK6gUtSouFP4pNxeO75ozwbposljcoPmhKGo6nso=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796290189; v=1; x=1796894989; b=OVcSlpMLm8hKZa39Z/DfKhNYpfbYb5lBMgj5Hbkr0hoMZ1jCH6jjYk+0IAILvsKHZmkipU06 BqgnspGVcUWS+m6EzYiCKP4MOYJaO4r0Eai4q1hc4OLkY67TdPeGQtI/qYX0tnjf7CXRecRh3eh sHwZ+fV3zkQ5z+YhFn//zIKo= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 3dfb2d978844866f; Thu, 03 Dec 2026 09:29:48 +0000 X-Mizu-Trace-ID: 3dfb2d978844866f X-Migadu-Flow: FLOW_OUT From: Peng Fan Date: Thu, 03 Dec 2026 17:29:15 +0800 Subject: [PATCH v2 3/8] irqchip/imx-intmux: Fix probe error path X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261203-imx-intmux-v2-3-a6db1eed3b5f@nxp.com> References: <20261203-imx-intmux-v2-0-a6db1eed3b5f@nxp.com> In-Reply-To: <20261203-imx-intmux-v2-0-a6db1eed3b5f@nxp.com> To: Thomas Gleixner , Radu Rendec , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Shengjiu Wang , Marc Zyngier Cc: linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, Peng Fan X-Mailer: b4 0.14.3 From: Peng Fan When setting up a channel fails after previous channels have been initialized, the error path only disables the clock. The chained handlers of those channels stay registered with handler data pointing into the devres-managed intmux_data, which is released when probe fails, leaving dangling pointers behind. The created IRQ domains and parent IRQ mappings are leaked as well. Unwind the initialized channels, tear down runtime PM and only then disable the clock. Mask each parent interrupt and wait for a running chained handler to finish before detaching it, so the rollback cannot race with an in-flight imx_intmux_irq_handler(). Also enable the clock before touching runtime PM so that a clock failure cannot leave runtime PM enabled with an unbalanced usage counter, and propagate a pm_runtime_set_active() failure after unwinding the usage count and clock reference. Fixes: 2fbb13961e74 ("irqchip: Add NXP INTMUX interrupt multiplexer support") Signed-off-by: Peng Fan --- drivers/irqchip/irq-imx-intmux.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c index 3b4eb9bd6678..06cf75a93373 100644 --- a/drivers/irqchip/irq-imx-intmux.c +++ b/drivers/irqchip/irq-imx-intmux.c @@ -229,16 +229,21 @@ static int imx_intmux_probe(struct platform_device *pdev) data->channum = channum; raw_spin_lock_init(&data->lock); - pm_runtime_get_noresume(&pdev->dev); - pm_runtime_set_active(&pdev->dev); - pm_runtime_enable(&pdev->dev); - ret = clk_prepare_enable(data->ipg_clk); if (ret) { dev_err(&pdev->dev, "failed to enable ipg clk: %d\n", ret); return ret; } + pm_runtime_get_noresume(&pdev->dev); + ret = pm_runtime_set_active(&pdev->dev); + if (ret) { + dev_err(&pdev->dev, "failed to set runtime PM active: %d\n", ret); + pm_runtime_put_noidle(&pdev->dev); + goto err_disable_clk; + } + pm_runtime_enable(&pdev->dev); + for (i = 0; i < channum; i++) { data->irqchip_data[i].chanidx = i; @@ -256,6 +261,7 @@ static int imx_intmux_probe(struct platform_device *pdev) if (!domain) { ret = -ENOMEM; dev_err(&pdev->dev, "failed to create IRQ domain\n"); + irq_dispose_mapping(data->irqchip_data[i].irq); goto out; } data->irqchip_data[i].domain = domain; @@ -279,6 +285,24 @@ static int imx_intmux_probe(struct platform_device *pdev) return 0; out: + while (i--) { + /* + * Mask the parent interrupt and wait for a handler that is + * already running to finish before its data and mappings are + * torn down. + */ + disable_irq(data->irqchip_data[i].irq); + irq_set_chained_handler_and_data(data->irqchip_data[i].irq, + NULL, NULL); + for (unsigned int hwirq = 0; hwirq < 32; hwirq++) + irq_dispose_mapping(irq_find_mapping(data->irqchip_data[i].domain, + hwirq)); + irq_domain_remove(data->irqchip_data[i].domain); + irq_dispose_mapping(data->irqchip_data[i].irq); + } + pm_runtime_disable(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); +err_disable_clk: clk_disable_unprepare(data->ipg_clk); return ret; } -- 2.56.0