lkml.org 
[lkml]   [2023]   [Mar]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] remoteproc: mediatek: Dereferencing a pointer that might be NULL
On Fri, 3 Mar 2023 at 03:28, Jason-ch Chen <jason-ch.chen@mediatek.com> wrote:
>
> From: jason-ch chen <Jason-ch.Chen@mediatek.com>
>
> The res might be NULL when calling resource_size.
>

"resource_size" ? What is that?

> Signed-off-by: jason-ch chen <Jason-ch.Chen@mediatek.com>
> ---
> drivers/remoteproc/mtk_scp.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
> index eacdf241f4ef..863d18f63f58 100644
> --- a/drivers/remoteproc/mtk_scp.c
> +++ b/drivers/remoteproc/mtk_scp.c
> @@ -829,6 +829,9 @@ static int scp_probe(struct platform_device *pdev)
> platform_set_drvdata(pdev, scp);
>
> res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sram");
> + if (!res)
> + return -ENODEV;
> +

Please have a look at the implementation of devm_ioremap_resource()
along with the function it calls and let me know if your patch is
needed.

> scp->sram_base = devm_ioremap_resource(dev, res);
> if (IS_ERR((__force void *)scp->sram_base)) {
> dev_err(dev, "Failed to parse and map sram memory\n");
> --
> 2.37.3
>

\
 
 \ /
  Last update: 2023-03-27 00:43    [W:0.081 / U:0.756 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site