Skip to contentSkip to conversation

ARM: DT: don't try to access physical address zero

PATCH New Nicolas Pitre 2 participants 2 messages Jun 9, 2011 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: DT: don't try to access physical address zero

From: Nicolas Pitre <[email protected]>

If the DT physical address is zero, this is equivalent to no DT. Especially when the actual RAM physical address is not located at zero, the result of phys_to_virt() would point to la-la-land and crash the kernel, which crash is completely silent this early during boot.

---

arch/arm/kernel/devtree.c +3 -0
index a701e42..0cdd7b4 100644
@@ -76,6 +76,9 @@ struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
 	unsigned long dt_root;
 	const char *model;
 
+	if (!dt_phys)
+		return NULL;
+
 	devtree = phys_to_virt(dt_phys);
 
 	/* check device tree validity */
#1 lore raw

PATCH 1/1 ARM: DT: don't try to access physical address zero

Quoted 9 lines · Nicolas Pitre

From: Nicolas Pitre <[email protected]>

If the DT physical address is zero, this is equivalent to no DT. Especially when the actual RAM physical address is not located at zero, the result of phys_to_virt() would point to la-la-land and crash the kernel, which crash is completely silent this early during boot.

Hmmm, I thought I had fixed that.

This is obviously correct.

Quoted 15 lines

---

arch/arm/kernel/devtree.c +3 -0
index a701e42..0cdd7b4 100644
@@ -76,6 +76,9 @@ struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys)
 	unsigned long dt_root;
 	const char *model;
 
+	if (!dt_phys)
+		return NULL;
+
 	devtree = phys_to_virt(dt_phys);
 
 	/* check device tree validity */