fdt: copy FDT data from kernel_args to kernel heap

Change-Id: Id7b18c582357b8eeaa2e6b7956da3db35ebded3a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6599
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
This commit is contained in:
X512 2023-06-13 06:58:18 +09:00 committed by waddlesplash
parent 2075595c78
commit 5d39116f10

View File

@ -225,6 +225,15 @@ fdt_bus_init(device_node* node, void** cookie)
if (!bus.IsSet())
return B_NO_MEMORY;
// gFDT is stored in kernel_args and will be freed, so copy it to kernel heap.
size_t size = fdt_totalsize(gFDT);
void* newFDT = malloc(size);
if (newFDT == NULL)
return B_NO_MEMORY;
memcpy(newFDT, gFDT, size);
gFDT = newFDT;
bus->node = node;
*cookie = bus.Detach();
return B_OK;