soc: mediatek: mtk-devapc: release IRQ before unmapping registers
Subsystems (2)
PATCH 1/1 soc: mediatek: mtk-devapc: release IRQ before unmapping registers
The managed IRQ remains registered until devres cleanup after remove returns, but remove explicitly unmaps the registers used by its handler.
An interrupt handler already in flight when stop_devapc() is called can continue accessing ctx->infra_base after iounmap().
Release and synchronize the IRQ before unmapping the register region.
This issue was identified during our ongoing static-analysis research while reviewing kernel code.
--- drivers/soc/mediatek/mtk-devapc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/soc/mediatek/mtk-devapc.c +3 -0
@@ -54,6 +54,7 @@ struct mtk_devapc_context {void __iomem *infra_base;struct clk *infra_clk;const struct mtk_devapc_data *data; +unsigned int irq; };static void clear_vio_status (struct mtk_devapc_context *ctx)
@@ -289,6 +290,7 @@ static int mtk_devapc_probe(struct platform_device *pdev)if (ret) goto err; + ctx->irq = devapc_irq;platform_set_drvdata (pdev, ctx);start_devapc (ctx);
@@ -305,6 +307,7 @@ static void mtk_devapc_remove(struct platform_device *pdev)struct mtk_devapc_context *ctx =platform_get_drvdata (pdev);stop_devapc (ctx); +devm_free_irq (&pdev->dev, ctx->irq, ctx);iounmap (ctx->infra_base); }
Quoted 9 lines · Myeonghun Pak
The managed IRQ remains registered until devres cleanup after remove returns, but remove explicitly unmaps the registers used by its handler.
An interrupt handler already in flight when
stop_devapc()is called can continue accessingctx->infra_baseafteriounmap().Release and synchronize the IRQ before unmapping the register region.
[...]
Applied to v7.4-next/soc, thanks!
[1/1] soc: mediatek: mtk-devapc: release IRQ before unmapping registers
commit: bf97386b6ba804df2e3a42933a4c955659a4263b
Cheers,
Angelo