* [PATCH] drivers: soc: sunxi: Fix possible null pointer dereference
@ 2025-04-12 16:57 Chenyuan Yang
2025-04-24 23:38 ` Andre Przywara
0 siblings, 1 reply; 2+ messages in thread
From: Chenyuan Yang @ 2025-04-12 16:57 UTC (permalink / raw)
To: wens, jernej.skrabec, samuel, arnd, hdegoede, mripard
Cc: linux-arm-kernel, linux-sunxi, linux-kernel, Chenyuan Yang
of_get_address() may return NULL which is later dereferenced.
Fix this bug by adding NULL check
This is similar to the commit c534b63bede6
("drm: vc4: Fix possible null pointer dereference").
Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
Fixes: 4af34b572a85 ("drivers: soc: sunxi: Introduce SoC driver to map SRAMs")
---
drivers/soc/sunxi/sunxi_sram.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/soc/sunxi/sunxi_sram.c b/drivers/soc/sunxi/sunxi_sram.c
index 2781a091a6a6..1853dcc806ea 100644
--- a/drivers/soc/sunxi/sunxi_sram.c
+++ b/drivers/soc/sunxi/sunxi_sram.c
@@ -122,6 +122,8 @@ static int sunxi_sram_show(struct seq_file *s, void *data)
continue;
sram_addr_p = of_get_address(sram_node, 0, NULL, NULL);
+ if (!sram_addr_p)
+ continue;
seq_printf(s, "sram@%08x\n",
be32_to_cpu(*sram_addr_p));
@@ -134,6 +136,8 @@ static int sunxi_sram_show(struct seq_file *s, void *data)
section_addr_p = of_get_address(section_node, 0,
NULL, NULL);
+ if (!section_addr_p)
+ continue;
seq_printf(s, "\tsection@%04x\t(%s)\n",
be32_to_cpu(*section_addr_p),
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drivers: soc: sunxi: Fix possible null pointer dereference
2025-04-12 16:57 [PATCH] drivers: soc: sunxi: Fix possible null pointer dereference Chenyuan Yang
@ 2025-04-24 23:38 ` Andre Przywara
0 siblings, 0 replies; 2+ messages in thread
From: Andre Przywara @ 2025-04-24 23:38 UTC (permalink / raw)
To: Chenyuan Yang
Cc: wens, jernej.skrabec, samuel, arnd, hdegoede, mripard,
linux-arm-kernel, linux-sunxi, linux-kernel
On Sat, 12 Apr 2025 11:57:00 -0500
Chenyuan Yang <chenyuan0y@gmail.com> wrote:
> of_get_address() may return NULL which is later dereferenced.
> Fix this bug by adding NULL check
>
> This is similar to the commit c534b63bede6
> ("drm: vc4: Fix possible null pointer dereference").
>
> Signed-off-by: Chenyuan Yang <chenyuan0y@gmail.com>
> Fixes: 4af34b572a85 ("drivers: soc: sunxi: Introduce SoC driver to map SRAMs")
That fix looks alright, indeed of_get_address() returns NULL if the
slightest bit in the property is not as expected, and we should check
for that.
I am just wondering if we should issue a firmware warning in this case,
instead of just silently skipping an entry.
Cheers,
Andre
> ---
> drivers/soc/sunxi/sunxi_sram.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/soc/sunxi/sunxi_sram.c b/drivers/soc/sunxi/sunxi_sram.c
> index 2781a091a6a6..1853dcc806ea 100644
> --- a/drivers/soc/sunxi/sunxi_sram.c
> +++ b/drivers/soc/sunxi/sunxi_sram.c
> @@ -122,6 +122,8 @@ static int sunxi_sram_show(struct seq_file *s, void *data)
> continue;
>
> sram_addr_p = of_get_address(sram_node, 0, NULL, NULL);
> + if (!sram_addr_p)
> + continue;
>
> seq_printf(s, "sram@%08x\n",
> be32_to_cpu(*sram_addr_p));
> @@ -134,6 +136,8 @@ static int sunxi_sram_show(struct seq_file *s, void *data)
>
> section_addr_p = of_get_address(section_node, 0,
> NULL, NULL);
> + if (!section_addr_p)
> + continue;
>
> seq_printf(s, "\tsection@%04x\t(%s)\n",
> be32_to_cpu(*section_addr_p),
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-04-24 23:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-12 16:57 [PATCH] drivers: soc: sunxi: Fix possible null pointer dereference Chenyuan Yang
2025-04-24 23:38 ` Andre Przywara
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).