Skip to contentSkip to conversation

armv8/fsl-lsch3: fdt: Check the pointer returned from call to a function may be NULL

PATCH New Alison Wang 2 participants 2 messages Sep 1, 2015 – Oct 30, 2015 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 armv8/fsl-lsch3: fdt: Check the pointer returned from call to a function may be NULL

Pointer 'reg' returned from call to function 'fdt_getprop' may be NULL, will be passed to function and may be dereferenced there by passing argument 1 to function 'of_read_number'. So check pointer 'reg' first.

---
 arch/arm/cpu/armv8/fsl-lsch3/fdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/cpu/armv8/fsl-lsch3/fdt.c +1 -1
index 567c419..922e8a0 100644
@@ -33,8 +33,8 @@ void ft_fixup_cpu(void *blob)
 	off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
 	while (off != -FDT_ERR_NOTFOUND) {
 		reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0);
-		core_id = of_read_number(reg, addr_cells);
 		if (reg) {
+			core_id = of_read_number(reg, addr_cells);
 			if (core_id  == 0 || (is_core_online(core_id))) {
 				val = spin_tbl_addr;
 				val += id_to_core(core_id) *
Signature · 1 line
2.1.0.27.g96db324
#1 lore raw

PATCH 1/1 armv8/fsl-lsch3: fdt: Check the pointer returned from call to a function may be NULL

Quoted 7 lines · Alison Wang

Pointer 'reg' returned from call to function 'fdt_getprop' may be NULL, will be passed to function and may be dereferenced there by passing argument 1 to function 'of_read_number'. So check pointer 'reg' first.

---

Applied to u-boot-fsl-qoriq. Awaiting upstream. Thanks.

York