Page MenuHomeFreeBSD

D59983.id187599.diff
No OneTemporary

D59983.id187599.diff

diff --git a/sys/kern/kern_jail.c b/sys/kern/kern_jail.c
--- a/sys/kern/kern_jail.c
+++ b/sys/kern/kern_jail.c
@@ -3432,14 +3432,11 @@
void
prison_hold(struct prison *pr)
{
-#ifdef INVARIANTS
- int was_valid = refcount_acquire_if_not_zero(&pr->pr_ref);
+ u_int old __diagused;
- KASSERT(was_valid,
- ("Trying to hold dead prison %p (jid=%d).", pr, pr->pr_id));
-#else
- refcount_acquire(&pr->pr_ref);
-#endif
+ old = refcount_acquire(&pr->pr_ref);
+ KASSERT(old > 0,
+ ("cannot hold a non-alive prison (jid=%d)", pr->pr_id));
}
/*
@@ -3478,19 +3475,12 @@
static void
prison_free_not_last(struct prison *pr)
{
-#ifdef INVARIANTS
- int lastref;
+ bool released __diagused;
- KASSERT(refcount_load(&pr->pr_ref) > 0,
- ("Trying to free dead prison %p (jid=%d).",
- pr, pr->pr_id));
- lastref = refcount_release(&pr->pr_ref);
- KASSERT(!lastref,
+ released = refcount_release(&pr->pr_ref);
+ KASSERT(!released,
("prison_free_not_last freed last ref on prison %p (jid=%d).",
pr, pr->pr_id));
-#else
- refcount_release(&pr->pr_ref);
-#endif
}
/*
@@ -3505,14 +3495,11 @@
void
prison_proc_hold(struct prison *pr)
{
-#ifdef INVARIANTS
- int was_alive = refcount_acquire_if_not_zero(&pr->pr_uref);
+ u_int old __diagused;
- KASSERT(was_alive,
- ("Cannot add a process to a non-alive prison (jid=%d)", pr->pr_id));
-#else
- refcount_acquire(&pr->pr_uref);
-#endif
+ old = refcount_acquire(&pr->pr_uref);
+ KASSERT(old > 0,
+ ("cannot add a process to a non-alive prison (jid=%d)", pr->pr_id));
}
/*
@@ -3529,8 +3516,6 @@
* This allows assurance that a locked prison will remain alive
* until it is unlocked.
*/
- KASSERT(refcount_load(&pr->pr_uref) > 0,
- ("Trying to kill a process in a dead prison (jid=%d)", pr->pr_id));
if (!refcount_release_if_not_last(&pr->pr_uref)) {
/*
* Don't remove the last user reference in this context,

File Metadata

Mime Type
text/plain
Expires
Fri, Sep 25, 6:29 PM (12 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39599350
Default Alt Text
D59983.id187599.diff (1 KB)

Event Timeline