[PATCH] drivers: soc: sunxi: Fix possible null pointer dereference

Chenyuan Yang chenyuan0y at gmail.com
Sat Apr 12 09:57:00 PDT 2025


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




More information about the linux-arm-kernel mailing list