diff options
author | John Baldwin <jhb@FreeBSD.org> | 2006-12-04 16:45:23 +0000 |
---|---|---|
committer | John Baldwin <jhb@FreeBSD.org> | 2006-12-04 16:45:23 +0000 |
commit | 5505470e4ab0f0fcf2decf3531dfaee0fb79d8fc (patch) | |
tree | 9189a13c98badf1c81bac72989148d787fd195bf /sys/kern/subr_rman.c | |
parent | daacddcac84ec02bfce7d249d54ac7a15b94717a (diff) | |
download | src-5505470e4ab0f0fcf2decf3531dfaee0fb79d8fc.tar.gz src-5505470e4ab0f0fcf2decf3531dfaee0fb79d8fc.zip |
Fix an edge case in rman_manage_region() where it didn't handle a resource
ending at ULONG_MAX properly. While here, use TAILQ_FOREACH_SAFE().
Tested by: "Stephane E. Potvin" <sepotvin at videotron-ca>
MFC after: 1 week
Notes
Notes:
svn path=/head/; revision=164881
Diffstat (limited to 'sys/kern/subr_rman.c')
-rw-r--r-- | sys/kern/subr_rman.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c index f59327a124da..b17ea74d391c 100644 --- a/sys/kern/subr_rman.c +++ b/sys/kern/subr_rman.c @@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> #include <sys/systm.h> #include <sys/kernel.h> +#include <sys/limits.h> #include <sys/lock.h> #include <sys/malloc.h> #include <sys/mutex.h> @@ -169,10 +170,12 @@ rman_manage_region(struct rman *rm, u_long start, u_long end) mtx_lock(rm->rm_mtx); /* Skip entries before us. */ - for (s = TAILQ_FIRST(&rm->rm_list); - s && s->r_end + 1 < r->r_start; - s = TAILQ_NEXT(s, r_link)) - ; + TAILQ_FOREACH(s, &rm->rm_list, r_link) { + if (s->r_end == ULONG_MAX) + break; + if (s->r_end + 1 >= r->r_start) + break; + } /* If we ran off the end of the list, insert at the tail. */ if (s == NULL) { |