Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Feb 2020 11:08:01 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r358245 - stable/11/sys/kern
Message-ID:  <202002221108.01MB81cs077981@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Sat Feb 22 11:08:01 2020
New Revision: 358245
URL: https://svnweb.freebsd.org/changeset/base/358245

Log:
  MFC r357984:
  sem_remove(): fix the loop that compacts sem array on semaphores removal.

Modified:
  stable/11/sys/kern/sysv_sem.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/sysv_sem.c
==============================================================================
--- stable/11/sys/kern/sysv_sem.c	Sat Feb 22 11:05:27 2020	(r358244)
+++ stable/11/sys/kern/sysv_sem.c	Sat Feb 22 11:08:01 2020	(r358245)
@@ -576,8 +576,9 @@ sem_remove(int semidx, struct ucred *cred)
 		    sema[i].u.sem_base > semakptr->u.sem_base)
 			mtx_lock_flags(&sema_mtx[i], LOP_DUPOK);
 	}
-	for (i = semakptr->u.sem_base - sem; i < semtot; i++)
-		sem[i] = sem[i + semakptr->u.sem_nsems];
+	for (i = semakptr->u.sem_base - sem + semakptr->u.sem_nsems;
+	    i < semtot; i++)
+		sem[i - semakptr->u.sem_nsems] = sem[i];
 	for (i = 0; i < seminfo.semmni; i++) {
 		if ((sema[i].u.sem_perm.mode & SEM_ALLOC) &&
 		    sema[i].u.sem_base > semakptr->u.sem_base) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002221108.01MB81cs077981>