* [PATCH] remoteproc: mediatek: Dereferencing a pointer that might be NULL
@ 2023-03-03 10:27 Jason-ch Chen
2023-03-03 18:20 ` Mathieu Poirier
0 siblings, 1 reply; 3+ messages in thread
From: Jason-ch Chen @ 2023-03-03 10:27 UTC (permalink / raw)
To: Bjorn Andersson, Mathieu Poirier, Matthias Brugger
Cc: Project_Global_Chrome_Upstream_Group, linux-kernel,
linux-mediatek, linux-arm-kernel, linux-remoteproc,
jason-ch chen
From: jason-ch chen <Jason-ch.Chen@mediatek.com>
The res might be NULL when calling resource_size.
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;
+
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] remoteproc: mediatek: Dereferencing a pointer that might be NULL
2023-03-03 10:27 [PATCH] remoteproc: mediatek: Dereferencing a pointer that might be NULL Jason-ch Chen
@ 2023-03-03 18:20 ` Mathieu Poirier
2023-03-09 8:24 ` Jason-ch Chen (陳建豪)
0 siblings, 1 reply; 3+ messages in thread
From: Mathieu Poirier @ 2023-03-03 18:20 UTC (permalink / raw)
To: Jason-ch Chen
Cc: Bjorn Andersson, Matthias Brugger,
Project_Global_Chrome_Upstream_Group, linux-kernel,
linux-mediatek, linux-arm-kernel, linux-remoteproc
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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] remoteproc: mediatek: Dereferencing a pointer that might be NULL
2023-03-03 18:20 ` Mathieu Poirier
@ 2023-03-09 8:24 ` Jason-ch Chen (陳建豪)
0 siblings, 0 replies; 3+ messages in thread
From: Jason-ch Chen (陳建豪) @ 2023-03-09 8:24 UTC (permalink / raw)
To: mathieu.poirier
Cc: linux-arm-kernel, matthias.bgg, linux-kernel, linux-mediatek,
bjorn.andersson, Project_Global_Chrome_Upstream_Group,
linux-remoteproc
Hi Mathieu,
On Fri, 2023-03-03 at 11:20 -0700, Mathieu Poirier wrote:
> 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.
>
Thanks for your reply.
It seems is patch is not 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
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-09 8:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-03 10:27 [PATCH] remoteproc: mediatek: Dereferencing a pointer that might be NULL Jason-ch Chen
2023-03-03 18:20 ` Mathieu Poirier
2023-03-09 8:24 ` Jason-ch Chen (陳建豪)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®