:: commit 68ad2db75527321c8f9dfe9958f9559a395184ad

mintsuki <mintsuki@protonmail.com> — 2024-06-27 23:01

parents: cc05481b89

dtb: Fix bugs introduced in cc05481b89f13c842645d5cacc78908d6a9f102e

diff --git a/common/lib/misc.c b/common/lib/misc.c
index 93b9fd45..754a70c7 100644
--- a/common/lib/misc.c
+++ b/common/lib/misc.c
@@ -124,9 +124,10 @@ void *get_device_tree_blob(size_t extra_size) {
 
         printv("efi: found dtb at %p, size %x\n", cur_table->VendorTable, s);
 
-        if (extra_size == (size_t)-1) {
-            extra_size = 0;
+        if (extra_size == 0) {
+            return cur_table->VendorTable;
         }
+
         void *new_tab = ext_mem_alloc(s + extra_size);
 
         ret = fdt_resize(cur_table->VendorTable, new_tab, s + extra_size);
@@ -137,7 +138,7 @@ void *get_device_tree_blob(size_t extra_size) {
         return new_tab;
     }
 
-    if (extra_size == (size_t)-1) {
+    if (extra_size == 0) {
         return NULL;
     }
 
diff --git a/common/sys/cpu_riscv.c b/common/sys/cpu_riscv.c
index f9677d91..052d1a78 100644
--- a/common/sys/cpu_riscv.c
+++ b/common/sys/cpu_riscv.c
@@ -225,7 +225,7 @@ static void init_riscv_fdt(const void *fdt) {
 }
 
 void init_riscv(void) {
-    void *fdt = get_device_tree_blob((size_t)-1);
+    void *fdt = get_device_tree_blob(0);
     if (fdt != NULL) {
         init_riscv_fdt(fdt);
     } else if (acpi_get_rsdp()) {
tab: 248 wrap: offon