smp_topo(): make it idempotent
If more than one call to the function occurs, it currently allocates the same amount from the group[] array, eventually leading to the memory corruption. Noted and reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D39981
This commit is contained in:
parent
9801e7c275
commit
d0f67f9757
@ -645,7 +645,14 @@ struct cpu_group *
|
|||||||
smp_topo(void)
|
smp_topo(void)
|
||||||
{
|
{
|
||||||
char cpusetbuf[CPUSETBUFSIZ], cpusetbuf2[CPUSETBUFSIZ];
|
char cpusetbuf[CPUSETBUFSIZ], cpusetbuf2[CPUSETBUFSIZ];
|
||||||
struct cpu_group *top;
|
static struct cpu_group *top = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The first call to smp_topo() is guaranteed to occur
|
||||||
|
* during the kernel boot while we are still single-threaded.
|
||||||
|
*/
|
||||||
|
if (top != NULL)
|
||||||
|
return (top);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check for a fake topology request for debugging purposes.
|
* Check for a fake topology request for debugging purposes.
|
||||||
|
Loading…
Reference in New Issue
Block a user