diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c index bea78326f889..80d07ba8dc38 100644 --- a/sys/kern/sysv_sem.c +++ b/sys/kern/sysv_sem.c @@ -1166,6 +1166,13 @@ semop(td, uap) goto done2; } + /* + * Renew the semaphore's pointer after wakeup since + * during msleep sem_base may have been modified and semptr + * is not valid any more + */ + semptr = &semakptr->u.sem_base[sopptr->sem_num]; + /* * The semaphore is still alive. Readjust the count of * waiting processes.