From: Chenyuan Yang <chenyuan0y@gmail.com>
To: wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org,
arnd@arndb.de, hdegoede@redhat.com, mripard@kernel.org
Cc: linux-arm-kernel@lists.infradead.org,
linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org,
Chenyuan Yang <chenyuan0y@gmail.com>
Subject: [PATCH] drivers: soc: sunxi: Fix possible null pointer dereference
Date: Sat, 12 Apr 2025 11:57:00 -0500 [thread overview]
Message-ID: <20250412165700.2298733-1-chenyuan0y@gmail.com> (raw)
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
next reply other threads:[~2025-04-12 16:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-12 16:57 Chenyuan Yang [this message]
2025-04-24 23:38 ` [PATCH] drivers: soc: sunxi: Fix possible null pointer dereference Andre Przywara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250412165700.2298733-1-chenyuan0y@gmail.com \
--to=chenyuan0y@gmail.com \
--cc=arnd@arndb.de \
--cc=hdegoede@redhat.com \
--cc=jernej.skrabec@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=mripard@kernel.org \
--cc=samuel@sholland.org \
--cc=wens@csie.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox