From: Gyeonggeon Choi <gychoi.dev@gmail.com>
To: robh@kernel.org, saravanak@google.com
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Gyeonggeon Choi <gychoi.dev@gmail.com>
Subject: [PATCH] drivers:of: Add null check for bus in of_match_bus
Date: Fri, 14 Jun 2024 00:01:34 +0900 [thread overview]
Message-ID: <20240613150134.66329-1-gychoi.dev@gmail.com> (raw)
Added a null check for the bus variable after calling of_match_bus.
This prevents potential null pointer dereference errors in subsequent
code, where bus->count_cells could cause a crash if bus is NULL.
Signed-off-by: Gyeonggeon Choi <gychoi.dev@gmail.com>
---
drivers/of/address.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/of/address.c b/drivers/of/address.c
index d669ce25b5f9..85f986d25870 100644
--- a/drivers/of/address.c
+++ b/drivers/of/address.c
@@ -504,6 +504,8 @@ static u64 __of_translate_address(struct device_node *node,
if (parent == NULL)
return OF_BAD_ADDR;
bus = of_match_bus(parent);
+ if (bus == NULL)
+ return OF_BAD_ADDR;
/* Count address cells & copy address locally */
bus->count_cells(dev, &na, &ns);
--
2.39.3 (Apple Git-146)
next reply other threads:[~2024-06-13 15:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 15:01 Gyeonggeon Choi [this message]
2024-06-13 15:44 ` [PATCH] drivers:of: Add null check for bus in of_match_bus Rob Herring
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=20240613150134.66329-1-gychoi.dev@gmail.com \
--to=gychoi.dev@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
--cc=saravanak@google.com \
/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