diff --git a/src/plugins/job_container/tmpfs/job_container_tmpfs.c b/src/plugins/job_container/tmpfs/job_container_tmpfs.c
index 4046dcbed35de8d4928ba503a00591986d1aa4fc..a5cda3afbc891dfef7cdfd322e8b403cb1fc2580 100644
--- a/src/plugins/job_container/tmpfs/job_container_tmpfs.c
+++ b/src/plugins/job_container/tmpfs/job_container_tmpfs.c
@@ -410,8 +410,8 @@ extern int container_p_create(uint32_t job_id)
 		    MAP_SHARED|MAP_ANONYMOUS, -1, 0);
 	if (sem2 == MAP_FAILED) {
 		error("%s: mmap failed: %s", __func__, strerror(errno));
-		munmap(sem1, sizeof(*sem1));
 		sem_destroy(sem1);
+		munmap(sem1, sizeof(*sem1));
 		rc = -1;
 		goto exit2;
 	}
@@ -475,10 +475,10 @@ extern int container_p_create(uint32_t job_id)
 			goto child_exit;
 		}
 	child_exit:
-		munmap(sem1, sizeof(*sem1));
 		sem_destroy(sem1);
-		munmap(sem2, sizeof(*sem2));
+		munmap(sem1, sizeof(*sem1));
 		sem_destroy(sem2);
+		munmap(sem2, sizeof(*sem2));
 
 		if (!rc) {
 			rc = _mount_private_shm();
@@ -551,10 +551,10 @@ extern int container_p_create(uint32_t job_id)
 	}
 
 exit1:
-	munmap(sem1, sizeof(*sem1));
 	sem_destroy(sem1);
-	munmap(sem2, sizeof(*sem2));
+	munmap(sem1, sizeof(*sem1));
 	sem_destroy(sem2);
+	munmap(sem2, sizeof(*sem2));
 
 exit2:
 	if (rc) {