Keep proper track of nsegs counter: sem_free is called for all
allocated semaphores, so it's wrong to increase it conditionally, in this case for every over-the-limit semaphore nsegs is decreased without being previously increased. PR: kern/123685 Approved by: cognet (mentor)
This commit is contained in:
parent
8f581f70ee
commit
4f61d04fd8
@ -221,14 +221,13 @@ sem_create(struct thread *td, const char *name, struct ksem **ksret,
|
||||
sem_enter(td->td_proc, ret);
|
||||
*ksret = ret;
|
||||
mtx_lock(&sem_lock);
|
||||
if (nsems >= p31b_getcfg(CTL_P1003_1B_SEM_NSEMS_MAX)) {
|
||||
nsems++;
|
||||
if (nsems > p31b_getcfg(CTL_P1003_1B_SEM_NSEMS_MAX)) {
|
||||
sem_leave(td->td_proc, ret);
|
||||
sem_free(ret);
|
||||
error = ENFILE;
|
||||
} else {
|
||||
nsems++;
|
||||
} else
|
||||
error = 0;
|
||||
}
|
||||
mtx_unlock(&sem_lock);
|
||||
return (error);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user