From 6a93e36b5f741e43bb250fde59d52fac4907a6fd Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 11 Apr 2015 22:57:13 +0000 Subject: Correct an off-by-one error in vm_reserv_reclaim_contig() that results in an infinite loop. Submitted by: Svatopluk Kraus MFC after: 1 week --- sys/vm/vm_reserv.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'sys/vm') diff --git a/sys/vm/vm_reserv.c b/sys/vm/vm_reserv.c index 585a7494060c..b74c768f48e1 100644 --- a/sys/vm/vm_reserv.c +++ b/sys/vm/vm_reserv.c @@ -983,8 +983,18 @@ vm_reserv_reclaim_contig(u_long npages, vm_paddr_t low, vm_paddr_t high, break; } else if ((pa & (alignment - 1)) != 0 || ((pa ^ (pa + size - 1)) & ~(boundary - 1)) != 0) { - /* Continue with this reservation. */ - hi = lo; + /* + * The current page doesn't meet the alignment + * and/or boundary requirements. Continue + * searching this reservation until the rest + * of its free pages are either excluded or + * exhausted. + */ + hi = lo + 1; + if (hi >= NBPOPMAP) { + hi = 0; + i++; + } continue; } /* Find the next used page. */ -- cgit v1.2.3