summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_rman.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2012-05-31 17:27:05 +0000
committerimp <imp@FreeBSD.org>2012-05-31 17:27:05 +0000
commitce8d6b964cd81ce2cf94dffa17edf9237a618e29 (patch)
tree6420c311a113ce69eeec82df6e2d6dcabe594ff1 /sys/kern/subr_rman.c
parent2599ce43d6c7a0270289814f48ca08ccd9d2d736 (diff)
downloadFreeBSD-src-ce8d6b964cd81ce2cf94dffa17edf9237a618e29.zip
FreeBSD-src-ce8d6b964cd81ce2cf94dffa17edf9237a618e29.tar.gz
Unlock in the error path to prevent a lock leak.
PR: 162174 Submitted by: Ian Lepore MFC after: 2 weeks
Diffstat (limited to 'sys/kern/subr_rman.c')
-rw-r--r--sys/kern/subr_rman.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c
index db8eb2f..e43dfcf 100644
--- a/sys/kern/subr_rman.c
+++ b/sys/kern/subr_rman.c
@@ -161,6 +161,7 @@ int
rman_manage_region(struct rman *rm, u_long start, u_long end)
{
struct resource_i *r, *s, *t;
+ int rv = 0;
DPRINTF(("rman_manage_region: <%s> request: start %#lx, end %#lx\n",
rm->rm_descr, start, end));
@@ -188,13 +189,17 @@ rman_manage_region(struct rman *rm, u_long start, u_long end)
TAILQ_INSERT_TAIL(&rm->rm_list, r, r_link);
} else {
/* Check for any overlap with the current region. */
- if (r->r_start <= s->r_end && r->r_end >= s->r_start)
- return EBUSY;
+ if (r->r_start <= s->r_end && r->r_end >= s->r_start) {
+ rv = EBUSY;
+ goto out;
+ }
/* Check for any overlap with the next region. */
t = TAILQ_NEXT(s, r_link);
- if (t && r->r_start <= t->r_end && r->r_end >= t->r_start)
- return EBUSY;
+ if (t && r->r_start <= t->r_end && r->r_end >= t->r_start) {
+ rv = EBUSY;
+ goto out;
+ }
/*
* See if this region can be merged with the next region. If
@@ -225,9 +230,9 @@ rman_manage_region(struct rman *rm, u_long start, u_long end)
TAILQ_INSERT_BEFORE(s, r, r_link);
}
}
-
+out:
mtx_unlock(rm->rm_mtx);
- return 0;
+ return rv;
}
int
OpenPOWER on IntegriCloud