summaryrefslogtreecommitdiff
path: root/src/cpu
diff options
context:
space:
mode:
authorArthur Heymans <arthur@aheymans.xyz>2022-11-25 13:36:26 +0100
committerFelix Held <felix-coreboot@felixheld.de>2022-12-14 13:51:40 +0000
commitdb65dd60fb11e3d38dbdd9a2e2f64d6ea7ef7576 (patch)
tree72d00caa585173b72aac87c7f02b74993b8f81f2 /src/cpu
parent3c8a3d1295e7f26e622e35ae7241044017ec771b (diff)
cpu/x86/mp_init.c: Improve AP entry point
Make sure that a pointer exists before dereferencing it. Change-Id: I1a9833bb9686451224249efe599346f64dc37874 Signed-off-by: Arthur Heymans <arthur@aheymans.xyz> Reviewed-on: https://review.coreboot.org/c/coreboot/+/70011 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
Diffstat (limited to 'src/cpu')
-rw-r--r--src/cpu/x86/mp_init.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/cpu/x86/mp_init.c b/src/cpu/x86/mp_init.c
index acc1323967..f00418547e 100644
--- a/src/cpu/x86/mp_init.c
+++ b/src/cpu/x86/mp_init.c
@@ -182,9 +182,16 @@ static asmlinkage void ap_init(unsigned int index)
enable_lapic();
setup_lapic_interrupts();
- struct device *dev = g_cpu_bus->children;
- for (unsigned int i = index; i > 0; i--)
- dev = dev->sibling;
+ struct device *dev;
+ int i = 0;
+ for (dev = g_cpu_bus->children; dev; dev = dev->sibling)
+ if (i++ == index)
+ break;
+
+ if (!dev) {
+ printk(BIOS_ERR, "Could not find allocated device for index %u\n", index);
+ return;
+ }
set_cpu_info(index, dev);