kernel: dont block allocating kstack for new processes

Have newproc() fail returning nil if we can't allocate
the kernel stack instead of locking up in smalloc().
This commit is contained in:
cinap_lenrek 2021-10-16 13:12:59 +00:00
parent 4c7745b202
commit a557c515c8

View file

@ -634,7 +634,7 @@ newproc(void)
lock(&procalloc);
p = procalloc.free;
if(p == nil){
if(p == nil || (p->kstack == nil && (p->kstack = malloc(KSTACK)) == nil)){
unlock(&procalloc);
return nil;
}
@ -655,8 +655,6 @@ newproc(void)
p->nlocks = 0;
p->delaysched = 0;
p->trace = 0;
if(p->kstack == nil)
p->kstack = smalloc(KSTACK);
/* sched params */
p->mp = nil;