Skip to content

Commit

Permalink
fdt: copy FDT data from kernel_args to kernel heap
Browse files Browse the repository at this point in the history
Change-Id: Id7b18c582357b8eeaa2e6b7956da3db35ebded3a
  • Loading branch information
X547 committed Jun 13, 2023
1 parent 0bf30ae commit 8136b7a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/add-ons/kernel/bus_managers/fdt/fdt_module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,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;
Expand Down

0 comments on commit 8136b7a

Please sign in to comment.