From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796286509; b=oBxosuM8YdjN0dNw5/+jwsqo9R7kNpnrRi8ujCsJnUswbC7Yx+p81HCIZxPMEIh/D2PP clxzBMQ+xaUk597OcyW+KMpjzed+4/eUbE7c02OsUduNBGpBzcM7ipLZ5V5HuQy2iLre0 EoD4+o3vqgkB5Iemws4tnaEhNtYy4j/fc0K73sFm34ETYfExD9CrIVEFAnO2xSIUl6wbd WKZxN8rxuivcvLBKlyZoDYcerOWYD6Urh9UlkQQL+b6b2icwLDY8GUoEdwuP2Ya/6jQZv lur3OuJSluCw5n667EmxeuyjYbCdGa/uCTMYSnmlo6qAlFPyu3B80Xo5M+X0kmjsY2g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796286509; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Type: Content-Transfer-Encoding; bh=OqSi2+KBfFbrsTRNQeoydmEXh0lBKHZTA6jUXwCzaP4=; b=33ufIw5xkyLiG0c1cJIcBl6gGfbRxxJRNa6qzcH0Xx+bWQ/Y+wRP0GVpofI6HzotF/Pp XbspMIs22NoJi6/UpqidP7Dolk4PlzoI62to6Vz9W4yP3ZTjfJXqi0byFwcvSqOvY/KBF NFTSw5N5qq3uMQipYlto4tsenJTP2oxmYzgRUgWVFVxGoKMsKg7fXoOn3B6LraqBm7610 iM2iuzHdI/s+zNg9BDWHTokhVb9aW8sEwe7tBePjtIG+6apU9t7JI1X0l7urliEa7JYc0 6ZMPCHnmgj2vE8pXHPcrqUUygknnEGuXmO0LuSNtcdqMrJDy6Q5wRRy1oMMnkzfwCOw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KVNzkDb+; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B59C7606A690; Thu, 3 Dec 2026 08:28:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KVNzkDb+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACD531F0089A; Thu, 3 Dec 2026 08:28:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796286509; bh=OqSi2+KBfFbrsTRNQeoydmEXh0lBKHZTA6jUXwCzaP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KVNzkDb+wH/hCX28fI1QGoldy5NhC4QIByl2b2oLZcu5czoXlbL4+TDWFNPpPMy03 SXFkUtJCkZVMWeqDTlbchW+88eyP7y+ZtCKU269eRDElQnd6G/E49esZzBUVd0icJE A3RlmsRO0iraxkMNH2aWkiSluHRFG9N9jDFB1rw8+/0Z+qxS2nVDXBxBhB5SPo0zLu 0gPdnmuH/genbnqbDLkXXRXWmlPdn2M2FLCJg51T49VIFgGIN1m0sovj7ouren6zIg JhB1VIkRupgjp7y6uKAxJ8epUTQgX5XAMd3P6YoMdHvLMTR+GcZgYwy2QdqtWTtm0x 85qN2ncPrLf9Q== From: Lee Jones To: lee@kernel.org Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Chen-Yu Tsai , Jassi Brar , Jernej Skrabec , linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, Philipp Zabel , Samuel Holland Subject: [PATCH 07/10] mailbox: sun6i-msgbox: Free IRQ before disabling clock on teardown Date: Thu, 3 Dec 2026 08:28:07 +0000 Message-ID: X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog In-Reply-To: References: 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: 8bit sun6i_msgbox_probe() requests the interrupt using devm_request_irq() before initialising mbox->controller and mbox->lock, while sun6i_msgbox_remove() manually calls mbox_controller_unregister() and clk_disable_unprepare() before devres frees the IRQ. An interrupt arriving during probe failure or device removal can access unclocked MMIO registers or freed controller data in sun6i_msgbox_irq(). Retrieve the IRQ via platform_get_irq() and register it with request_irq() after initialising mbox->controller and mbox->lock, then explicitly call free_irq() before disabling the clock in both the probe error path and sun6i_msgbox_remove(). Fixes: 25831c44b0b7 ("mailbox: sun6i-msgbox: Add a new mailbox driver") Closes: https://sashiko.dev/#/bug/linux-b10c9846-995f-40c3-a18c-97b9cb0d0611 Cc: stable@vger.kernel.org Signed-off-by: Lee Jones --- Cc: Chen-Yu Tsai Cc: Jassi Brar Cc: Jernej Skrabec Cc: linux-arm-kernel@lists.infradead.org Cc: linux-sunxi@lists.linux.dev Cc: Philipp Zabel Cc: Samuel Holland drivers/mailbox/sun6i-msgbox.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/mailbox/sun6i-msgbox.c b/drivers/mailbox/sun6i-msgbox.c index 1cbc4d478beb..4c5669035420 100644 --- a/drivers/mailbox/sun6i-msgbox.c +++ b/drivers/mailbox/sun6i-msgbox.c @@ -12,7 +12,6 @@ #include #include #include -#include #include #include #include @@ -48,6 +47,7 @@ struct sun6i_msgbox { struct clk *clk; spinlock_t lock; void __iomem *regs; + int irq; }; static bool sun6i_msgbox_last_tx_done(struct mbox_chan *chan); @@ -255,11 +255,6 @@ static int sun6i_msgbox_probe(struct platform_device *pdev) /* Disable all IRQs for this end of the msgbox. */ writel(0, mbox->regs + LOCAL_IRQ_EN_REG); - ret = devm_request_irq(dev, irq_of_parse_and_map(dev->of_node, 0), - sun6i_msgbox_irq, 0, dev_name(dev), mbox); - if (ret) - goto err_disable_unprepare; - mbox->controller.dev = dev; mbox->controller.ops = &sun6i_msgbox_chan_ops; mbox->controller.chans = chans; @@ -271,14 +266,26 @@ static int sun6i_msgbox_probe(struct platform_device *pdev) spin_lock_init(&mbox->lock); platform_set_drvdata(pdev, mbox); + mbox->irq = platform_get_irq(pdev, 0); + if (mbox->irq < 0) { + ret = mbox->irq; + goto err_disable_unprepare; + } + + ret = request_irq(mbox->irq, sun6i_msgbox_irq, 0, dev_name(dev), mbox); + if (ret) + goto err_disable_unprepare; + ret = mbox_controller_register(&mbox->controller); if (ret) { dev_err(dev, "Failed to register controller: %d\n", ret); - goto err_disable_unprepare; + goto err_free_irq; } return 0; +err_free_irq: + free_irq(mbox->irq, mbox); err_disable_unprepare: clk_disable_unprepare(mbox->clk); @@ -290,6 +297,7 @@ static void sun6i_msgbox_remove(struct platform_device *pdev) struct sun6i_msgbox *mbox = platform_get_drvdata(pdev); mbox_controller_unregister(&mbox->controller); + free_irq(mbox->irq, mbox); /* See the comment in sun6i_msgbox_probe about the reset line. */ clk_disable_unprepare(mbox->clk); } -- 2.56.1.911.g883d8bcb20-goog