summaryrefslogtreecommitdiff
path: root/sys/kern/sysv_sem.c
diff options
context:
space:
mode:
authorMatthew Dempsky <matthew@cvs.openbsd.org>2013-11-25 23:15:59 +0000
committerMatthew Dempsky <matthew@cvs.openbsd.org>2013-11-25 23:15:59 +0000
commit363922592d53d3db6ac4873fcc21776988c9ade4 (patch)
tree93badee1eaaf1c4fed6aa0d785998ecb768f8fe7 /sys/kern/sysv_sem.c
parenta5e5fbade1171949d294937d5ea24e71d5a0319f (diff)
Fix infinite loop pointed out by clang/brad.
ok guenther
Diffstat (limited to 'sys/kern/sysv_sem.c')
-rw-r--r--sys/kern/sysv_sem.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c
index 2789670ddd7..0b6da202ef8 100644
--- a/sys/kern/sysv_sem.c
+++ b/sys/kern/sysv_sem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sysv_sem.c,v 1.44 2012/10/21 19:00:48 beck Exp $ */
+/* $OpenBSD: sysv_sem.c,v 1.45 2013/11/25 23:15:58 matthew Exp $ */
/* $NetBSD: sysv_sem.c,v 1.26 1996/02/09 19:00:25 christos Exp $ */
/*
@@ -713,17 +713,16 @@ done:
* we applied them. This guarantees that we won't run
* out of space as we roll things back out.
*/
- if (i != 0) {
- for (j = i - 1; j >= 0; j--) {
- if ((sops[j].sem_flg & SEM_UNDO) == 0)
- continue;
- adjval = sops[j].sem_op;
- if (adjval == 0)
- continue;
- if (semundo_adjust(p, &suptr, semid,
- sops[j].sem_num, adjval) != 0)
- panic("semop - can't undo undos");
- }
+ for (j = i; j > 0;) {
+ j--;
+ if ((sops[j].sem_flg & SEM_UNDO) == 0)
+ continue;
+ adjval = sops[j].sem_op;
+ if (adjval == 0)
+ continue;
+ if (semundo_adjust(p, &suptr, semid,
+ sops[j].sem_num, adjval) != 0)
+ panic("semop - can't undo undos");
}
for (j = 0; j < nsops; j++)