public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers:of: Add null check for bus in of_match_bus
@ 2024-06-13 15:01 Gyeonggeon Choi
  2024-06-13 15:44 ` Rob Herring
  0 siblings, 1 reply; 2+ messages in thread
From: Gyeonggeon Choi @ 2024-06-13 15:01 UTC (permalink / raw)
  To: robh, saravanak; +Cc: devicetree, linux-kernel, Gyeonggeon Choi

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)


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-13 15:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-13 15:01 [PATCH] drivers:of: Add null check for bus in of_match_bus Gyeonggeon Choi
2024-06-13 15:44 ` Rob Herring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox