[PATCH] boot: Ensure that ranges is not used uninitialised

Andrew Goodbody andrew.goodbody at linaro.org
Fri Jun 27 13:51:02 CEST 2025


The local variable ranges may be used uninitialised if the function
fdt_get_dma_range is called with node < 0. Ensure this does not
happen by initialising ranges when declared.

This issue was found with Smatch.

Signed-off-by: Andrew Goodbody <andrew.goodbody at linaro.org>
---
 boot/fdt_support.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/boot/fdt_support.c b/boot/fdt_support.c
index 92f2f534ee0..4f63ce9a763 100644
--- a/boot/fdt_support.c
+++ b/boot/fdt_support.c
@@ -1547,7 +1547,7 @@ int fdt_get_dma_range(const void *blob, int node, phys_addr_t *cpu,
 {
 	bool found_dma_ranges = false;
 	struct of_bus *bus_node;
-	const fdt32_t *ranges;
+	const fdt32_t *ranges = NULL;
 	int na, ns, pna, pns;
 	int parent = node;
 	int ret = 0;

---
base-commit: 359e3012921f2fc2d43f3c4e320a752173f82b82
change-id: 20250627-boot_fdt_fix-e4e56d956c8a

Best regards,
-- 
Andrew Goodbody <andrew.goodbody at linaro.org>



More information about the U-Boot mailing list