[PATCH] remoteproc: mediatek: Unregister init IPI on share buffer failure

Haoxiang Li haoxiang_li2024 at 163.com
Tue Jun 23 06:38:44 PDT 2026


scp_rproc_init() registers the SCP init IPI before allocating the IPI
share buffer. If the share buffer allocation fails, the error path jumps
directly to release_dev_mem and leaves the init IPI registered.

Route that error path through the IPI unregister label so the registered
handler is cleared before unwinding the remaining resources.

Fixes: c08a82494500 ("remoteproc: mediatek: Support setting DRAM and IPI shared buffer sizes")
Signed-off-by: Haoxiang Li <haoxiang_li2024 at 163.com>
---
 drivers/remoteproc/mtk_scp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
index 85a74c9ec521..648b69f96624 100644
--- a/drivers/remoteproc/mtk_scp.c
+++ b/drivers/remoteproc/mtk_scp.c
@@ -1227,7 +1227,7 @@ static struct mtk_scp *scp_rproc_init(struct platform_device *pdev,
 	if (!scp->share_buf) {
 		dev_err(dev, "Failed to allocate IPI share buffer\n");
 		ret = -ENOMEM;
-		goto release_dev_mem;
+		goto unregister_ipi;
 	}
 
 	init_waitqueue_head(&scp->run.wq);
@@ -1248,9 +1248,10 @@ static struct mtk_scp *scp_rproc_init(struct platform_device *pdev,
 
 remove_subdev:
 	scp_remove_rpmsg_subdev(scp);
-	scp_ipi_unregister(scp, SCP_IPI_INIT);
 	kfree(scp->share_buf);
 	scp->share_buf = NULL;
+unregister_ipi:
+	scp_ipi_unregister(scp, SCP_IPI_INIT);
 release_dev_mem:
 	scp_unmap_memory_region(scp);
 	for (i = 0; i < SCP_IPI_MAX; i++)
-- 
2.25.1




More information about the linux-arm-kernel mailing list