diff options
author | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2024-08-05 13:46:17 +0000 |
---|---|---|
committer | Vitaliy Makkoveev <mvs@cvs.openbsd.org> | 2024-08-05 13:46:17 +0000 |
commit | 03c5f0a38643fd6fabfbb97d8ab4f21324927a23 (patch) | |
tree | 35cb3cd0188327433100f0ad06031e5b44e7ef4a /sys | |
parent | 3dd9b7a70981ca377941a3d52202c6b468563345 (diff) |
Take `sysctl_lock' before kernel lock.
ok bluhm
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_sysctl.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index f42fdd8ce8a..47deb313204 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_sysctl.c,v 1.430 2024/08/02 14:34:45 mvs Exp $ */ +/* $OpenBSD: kern_sysctl.c,v 1.431 2024/08/05 13:46:16 mvs Exp $ */ /* $NetBSD: kern_sysctl.c,v 1.17 1996/05/20 17:49:05 mrg Exp $ */ /*- @@ -172,26 +172,25 @@ sysctl_vslock(void *addr, size_t len) { int error; - KERNEL_LOCK(); error = rw_enter(&sysctl_lock, RW_WRITE|RW_INTR); if (error) - goto out; + return (error); + KERNEL_LOCK(); if (addr) { if (atop(len) > uvmexp.wiredmax - uvmexp.wired) { error = ENOMEM; - goto out2; + goto out; } error = uvm_vslock(curproc, addr, len, PROT_READ | PROT_WRITE); if (error) - goto out2; + goto out; } return (0); -out2: - rw_exit_write(&sysctl_lock); out: KERNEL_UNLOCK(); + rw_exit_write(&sysctl_lock); return (error); } @@ -202,8 +201,8 @@ sysctl_vsunlock(void *addr, size_t len) if (addr) uvm_vsunlock(curproc, addr, len); - rw_exit_write(&sysctl_lock); KERNEL_UNLOCK(); + rw_exit_write(&sysctl_lock); } int |