[PATCH] remoteproc: mediatek: Fix error code in scp_rproc_init()

Dan Carpenter dan.carpenter at linaro.org
Sat May 4 04:26:46 PDT 2024


Set the error code to ERR_PTR(-ENOMEM).  Otherwise if there is an
allocation failure it leads to a NULL dereference in the caller.

Fixes: c08a82494500 ("remoteproc: mediatek: Support setting DRAM and IPI shared buffer sizes")
Signed-off-by: Dan Carpenter <dan.carpenter at linaro.org>
---
 drivers/remoteproc/mtk_scp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
index e281d28242dd..b8498772dba1 100644
--- a/drivers/remoteproc/mtk_scp.c
+++ b/drivers/remoteproc/mtk_scp.c
@@ -1156,6 +1156,7 @@ static struct mtk_scp *scp_rproc_init(struct platform_device *pdev,
 	scp->share_buf = kzalloc(scp_sizes->ipi_share_buffer_size, GFP_KERNEL);
 	if (!scp->share_buf) {
 		dev_err(dev, "Failed to allocate IPI share buffer\n");
+		ret = -ENOMEM;
 		goto release_dev_mem;
 	}
 
-- 
2.43.0




More information about the Linux-mediatek mailing list