- if (suptr->un_cnt != limitseminfo.semume) {
- SYSV_SEM_SUBSYS_UNLOCK();
- /*
- * Unlocking opens the door to race conditions. Someone else
- * could be trying to allocate the same thing at this point,
- * so we'll have to check if we lost the race.
- */
- MALLOC(new_sueptr, struct undo *, sizeof (struct undo),
- M_SYSVSEM, M_WAITOK);
- SYSV_SEM_SUBSYS_LOCK();
- if (new_sueptr == NULL) {
- return ENOMEM;
- }
- /*
- * There might be other threads doing the same thing for this
- * process, so check again if an "undo" entry exists for that
- * semaphore.
- */
- goto lookup;
- } else
- return(EINVAL);
- return(0);
+ /* allocate a new semaphore undo entry */
+ MALLOC(new_sueptr, struct undo *, sizeof (struct undo),
+ M_SYSVSEM, M_WAITOK);
+ if (new_sueptr == NULL) {
+ return ENOMEM;
+ }
+
+ /* fill in the new semaphore undo entry */
+ new_sueptr->une_next = suptr->un_ent;
+ suptr->un_ent = new_sueptr;
+ suptr->un_cnt++;
+ new_sueptr->une_adjval = adjval;
+ new_sueptr->une_id = semid;
+ new_sueptr->une_num = semnum;
+
+ return 0;