diff -Nru linux-old/ipc/shm.c linux-new/ipc/shm.c
--- linux-old/ipc/shm.c	2002-10-23 20:58:12.000000000 -0400
+++ linux-new/ipc/shm.c	2002-10-23 22:02:56.000000000 -0400
@@ -122,9 +122,9 @@
  */
 static void shm_destroy (struct shmid_kernel *shp)
 {
-	shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
 	shm_rmid (shp->id);
 	shm_unlock(shp->id);
+	shm_tot -= (shp->shm_segsz + PAGE_SIZE - 1) >> PAGE_SHIFT;
 	shmem_lock(shp->shm_file, 0);
 	fput (shp->shm_file);
 	kfree (shp);
