:: commit ad262c8fbb5163308650162d4dc4bc244b0d2cf0

mintsuki <mintsuki@protonmail.com> — 2024-06-30 22:21

parents: 0a873b5303

smp: Return NULL instead of 0 CPU count if no processors were started

diff --git a/common/sys/smp.c b/common/sys/smp.c
index 23dd1d8a..5fe06e4b 100644
--- a/common/sys/smp.c
+++ b/common/sys/smp.c
@@ -177,6 +177,10 @@ struct limine_smp_info *init_smp(size_t   *cpu_count,
         }
     }
 
+    if (max_cpus == 0) {
+        return NULL;
+    }
+
     struct limine_smp_info *ret = ext_mem_alloc(max_cpus * sizeof(struct limine_smp_info));
     *cpu_count = 0;
 
@@ -261,6 +265,11 @@ struct limine_smp_info *init_smp(size_t   *cpu_count,
         }
     }
 
+    if (*cpu_count == 0) {
+        pmm_free(ret, max_cpus * sizeof(struct limine_smp_info));
+        return NULL;
+    }
+
     return ret;
 }
 
tab: 248 wrap: offon