drivers:of: Add null check for bus in of_match_bus
PATCH 1/1 drivers:of: Add null check for bus in of_match_bus
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 <[email protected]>
--- drivers/of/address.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/of/address.c +2 -0
@@ -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);
Signature · 1 line
2.39.3 (Apple Git-146)
Rob Herring
maintainerQuoted 4 lines · 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, wherebus->count_cellscould cause a crash if bus is NULL.
Go read of_match_bus(). It never returns NULL and if somehow it did, we'll BUG() first.
Quoted 22 lines
Signed-off-by Gyeonggeon Choi <[email protected]>--- drivers/of/address.c | 2 ++ 1 file changed, 2 insertions(+)drivers/of/address.c +2
-1@@ -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)