diff options
author | jhb <jhb@FreeBSD.org> | 2011-04-29 18:41:21 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2011-04-29 18:41:21 +0000 |
commit | 08955ceac0e6a5e070d655c0f47e170747a075d7 (patch) | |
tree | f321d6b25b24b3e15d314a828cb978d9b0cadfa4 /sys/kern/subr_rman.c | |
parent | 67e72142a1251ce0ac4d06ca82beb414ff6ae9f7 (diff) | |
download | FreeBSD-src-08955ceac0e6a5e070d655c0f47e170747a075d7.zip FreeBSD-src-08955ceac0e6a5e070d655c0f47e170747a075d7.tar.gz |
Change rman_manage_region() to actually honor the rm_start and rm_end
constraints on the rman and reject attempts to manage a region that is out
of range.
- Fix various places that set rm_end incorrectly (to ~0 or ~0u instead of
~0ul).
- To preserve existing behavior, change rman_init() to set rm_start and
rm_end to allow managing the full range (0 to ~0ul) if they are not set by
the caller when rman_init() is called.
Diffstat (limited to 'sys/kern/subr_rman.c')
-rw-r--r-- | sys/kern/subr_rman.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c index cfa4983..4352278 100644 --- a/sys/kern/subr_rman.c +++ b/sys/kern/subr_rman.c @@ -138,6 +138,8 @@ rman_init(struct rman *rm) mtx_init(&rman_mtx, "rman head", NULL, MTX_DEF); } + if (rm->rm_start == 0 && rm->rm_end == 0) + rm->rm_end = ~0ul; if (rm->rm_type == RMAN_UNINIT) panic("rman_init"); if (rm->rm_type == RMAN_GAUGE) @@ -162,6 +164,8 @@ rman_manage_region(struct rman *rm, u_long start, u_long end) DPRINTF(("rman_manage_region: <%s> request: start %#lx, end %#lx\n", rm->rm_descr, start, end)); + if (start < rm->rm_start || end > rm->rm_end) + return EINVAL; r = int_alloc_resource(M_NOWAIT); if (r == NULL) return ENOMEM; |