diff --git a/ipc/sem.c b/ipc/sem.c
index 2705fbbc437453a6660f8b7753cc0fe707321558..eac3f46a59686f9b610a5abf430c2cb37fec1459 100644
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -445,13 +445,13 @@ again:
 		 * of the completed operation:
 		 * - if the operation modified the array, then restart from the
 		 *   head of the queue and check for threads that might be
-		 *   waiting for semaphore values to become 0.
+		 *   waiting for the new semaphore values.
 		 * - if the operation didn't modify the array, then just
 		 *   continue.
 		 */
 		alter = q->alter;
 		wake_up_sem_queue(q, error);
-		if (alter)
+		if (alter && !error)
 			goto again;
 	}
 }