Skip to contentSkip to conversation

remove magic +1 from shm segment count

PATCH New Manfred Spraul 1 participant 1 message Aug 8, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remove magic +1 from shm segment count

Hi,

Michael Kerrisk found a bug in the shm accounting code:
sysv shm allows to create SHMMNI+1 shared memory segments, instead of SHMMNI segments. The +1 is probably from the first shared anonymous mapping implementation that used the sysv code to implement shared anon mappings. The implementation got replaced, it's now the other way around (sysv uses the shared anon code), but the +1 remained.

Andrew - could you add the patch to your tree?

ipc/shm.c +1 -1
@@ -78,7 +78,7 @@
 
 static inline int shm_addid(struct shmid_kernel *shp)
 {
-	return ipc_addid(&shm_ids, &shp->shm_perm, shm_ctlmni+1);
+	return ipc_addid(&shm_ids, &shp->shm_perm, shm_ctlmni);
 }