diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2018-04-10 12:27:02 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2018-04-10 12:27:02 +0000 |
commit | 0acde2c1ca8233036a7f70d68450d68fff020785 (patch) | |
tree | 9008f54995fe1bf696a5496ff25b1a3c15b1a814 | |
parent | 0096c94cebb8ff00bc4a5b63c325578692676206 (diff) |
Fix stop condition for linear search by taking into account the search
direction, otherwise we might break the loop prematurely; ok stefan@
-rw-r--r-- | sys/uvm/uvm_addr.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/uvm/uvm_addr.c b/sys/uvm/uvm_addr.c index 896aee70a05..aa2f2e27459 100644 --- a/sys/uvm/uvm_addr.c +++ b/sys/uvm/uvm_addr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_addr.c,v 1.24 2017/01/23 01:10:10 patrick Exp $ */ +/* $OpenBSD: uvm_addr.c,v 1.25 2018/04/10 12:27:01 otto Exp $ */ /* * Copyright (c) 2011 Ariane van der Steldt <ariane@stack.nl> @@ -358,8 +358,8 @@ uvm_addr_linsearch(struct vm_map *map, struct uvm_addr_state *uaddr, entry = (direction == 1 ? RBT_NEXT(uvm_map_addr, entry) : RBT_PREV(uvm_map_addr, entry))) { - if (VMMAP_FREE_START(entry) > high || - VMMAP_FREE_END(entry) < low) { + if ((direction == 1 && VMMAP_FREE_START(entry) > high) || + (direction == -1 && VMMAP_FREE_END(entry) < low)) { break; } |