Skip to contentSkip to conversation

of/fdt: remove redundant memset in __unflatten_device_tree()

PATCH In review Sang-Heon Jeon 2 participants 3 messages Apr 18 – Apr 21 Device tree

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 of/fdt: remove redundant memset in __unflatten_device_tree()

All dt_alloc callbacks passed to __unflatten_device_tree() already return zero-initialized memory.

- kernel_tree_alloc uses kzalloc()
- early_init_dt_alloc_memory_arch() and dt_alloc_memory() both use memblock_alloc()

So remove redundant memset after the allocation. No funtional change.

---
dt-test result

[    0.529540] ### dt-test ### start of unittest - you will see error messages
[    0.532758] ### dt-test ### EXPECT \ : Duplicate name in testcase-data, renamed to "duplicate-name#1"
[    0.537608] ### dt-test ### EXPECT / : Duplicate name in testcase-data, renamed to "duplicate-name#1"

...

[    0.781700] ### dt-test ### EXPECT / : OF: resolver: overlay phandle fixup failed: -22
[    0.781718] ### dt-test ### EXPECT / : OF: resolver: node label 'this_label_does_not_exist' not found in live devicetree symbols table
[    0.781945] ### dt-test ### end of unittest - 423 passed, 0 failed

---
Hello,

While looking into boot information, I found a minor enhancement point. If I misunderstood anything, please feel free to let me know.

Thank you for taking valuable time to review this work.

Best Regards,
Sang-Heon Jeon

---
 drivers/of/fdt.c | 2 --
 1 file changed, 2 deletions(-)
drivers/of/fdt.c +0 -2
index becc855ff8b5..647bff2c4521 100644
@@ -391,8 +391,6 @@ void *__unflatten_device_tree(const void *blob,
 	if (!mem)
 		return NULL;
 
-	memset(mem, 0, size);
-
 	*(__be32 *)(mem + size) = cpu_to_be32(0xdeadbeef);
 
 	pr_debug("  unflattening %p...\n", mem);
Signature · 1 line
2.43.0
#1 lore raw
Quoted 8 lines · Sang-Heon Jeon

All dt_alloc callbacks passed to __unflatten_device_tree() already return zero-initialized memory.

- kernel_tree_alloc uses kzalloc()
- early_init_dt_alloc_memory_arch() and dt_alloc_memory() both use memblock_alloc()

So remove redundant memset after the allocation. No funtional change.

That is true now, but it wasn't the case before memblock became used on all arches.

I've updated the commit message with this info and applied.

Rob

#2 lore raw

Hi,

Quoted 10 lines · Rob Herring (Arm)
Quoted 7 lines · Sang-Heon Jeon

All dt_alloc callbacks passed to __unflatten_device_tree() already return zero-initialized memory.

- kernel_tree_alloc uses kzalloc()
- early_init_dt_alloc_memory_arch() and dt_alloc_memory() both use memblock_alloc()

Quoted 6 lines
Quoted 1 line

So remove redundant memset after the allocation. No funtional change.

That is true now, but it wasn't the case before memblock became used on all arches.

I've updated the commit message with this info and applied.

Thanks for spotting that and for your review :)

Quoted 1 line

Rob

Best Regards,
Sang-Heon Jeon