linux-remoteproc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] remoteproc: mediatek: Fix error code in scp_rproc_init()
@ 2024-05-04 11:26 Dan Carpenter
  2024-05-06 12:50 ` AngeloGioacchino Del Regno
  2024-05-06 19:42 ` Mathieu Poirier
  0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-05-04 11:26 UTC (permalink / raw)
  To: Olivia Wen
  Cc: Bjorn Andersson, Mathieu Poirier, Matthias Brugger,
	AngeloGioacchino Del Regno, linux-remoteproc, linux-mediatek,
	kernel-janitors

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@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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] remoteproc: mediatek: Fix error code in scp_rproc_init()
  2024-05-04 11:26 [PATCH] remoteproc: mediatek: Fix error code in scp_rproc_init() Dan Carpenter
@ 2024-05-06 12:50 ` AngeloGioacchino Del Regno
  2024-05-06 19:42 ` Mathieu Poirier
  1 sibling, 0 replies; 3+ messages in thread
From: AngeloGioacchino Del Regno @ 2024-05-06 12:50 UTC (permalink / raw)
  To: Dan Carpenter, Olivia Wen
  Cc: Bjorn Andersson, Mathieu Poirier, Matthias Brugger,
	linux-remoteproc, linux-mediatek, kernel-janitors

Il 04/05/24 13:26, Dan Carpenter ha scritto:
> 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@linaro.org>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] remoteproc: mediatek: Fix error code in scp_rproc_init()
  2024-05-04 11:26 [PATCH] remoteproc: mediatek: Fix error code in scp_rproc_init() Dan Carpenter
  2024-05-06 12:50 ` AngeloGioacchino Del Regno
@ 2024-05-06 19:42 ` Mathieu Poirier
  1 sibling, 0 replies; 3+ messages in thread
From: Mathieu Poirier @ 2024-05-06 19:42 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Olivia Wen, Bjorn Andersson, Matthias Brugger,
	AngeloGioacchino Del Regno, linux-remoteproc, linux-mediatek,
	kernel-janitors

On Sat, May 04, 2024 at 02:26:46PM +0300, Dan Carpenter wrote:
> 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@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;
>  	}

Applied

Thanks,
Mathieu

>  
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-05-06 19:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-04 11:26 [PATCH] remoteproc: mediatek: Fix error code in scp_rproc_init() Dan Carpenter
2024-05-06 12:50 ` AngeloGioacchino Del Regno
2024-05-06 19:42 ` Mathieu Poirier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).