diff options
author | 2005-07-03 22:56:07 +0000 | |
---|---|---|
committer | 2005-07-03 22:56:07 +0000 | |
commit | e1adf784e64d3764b4dcc6ed1cd0827606933e9d (patch) | |
tree | 520278511ead046d19758aa9c6a0ec208d2f1b30 | |
parent | Fix data_length values in simulationed MODE SENSE page 4 responses so (diff) | |
download | wireguard-openbsd-e1adf784e64d3764b4dcc6ed1cd0827606933e9d.tar.xz wireguard-openbsd-e1adf784e64d3764b4dcc6ed1cd0827606933e9d.zip |
malloc(M_WAITOK) implies sleeping, so we have to double check that
somebody else didn't beat us in uid_find().
-rw-r--r-- | sys/kern/kern_proc.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c index 2ba584ca631..eb39f67acb6 100644 --- a/sys/kern/kern_proc.c +++ b/sys/kern/kern_proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_proc.c,v 1.25 2005/03/10 17:26:10 tedu Exp $ */ +/* $OpenBSD: kern_proc.c,v 1.26 2005/07/03 22:56:07 tedu Exp $ */ /* $NetBSD: kern_proc.c,v 1.14 1996/02/09 18:59:41 christos Exp $ */ /* @@ -110,7 +110,7 @@ procinit() struct uidinfo * uid_find(uid_t uid) { - struct uidinfo *uip; + struct uidinfo *uip, *nuip; struct uihashhead *uipp; uipp = UIHASH(uid); @@ -119,12 +119,20 @@ uid_find(uid_t uid) break; if (uip) return (uip); - MALLOC(uip, struct uidinfo *, sizeof(*uip), M_PROC, M_WAITOK); - bzero(uip, sizeof(*uip)); - LIST_INSERT_HEAD(uipp, uip, ui_hash); - uip->ui_uid = uid; + MALLOC(nuip, struct uidinfo *, sizeof(*nuip), M_PROC, M_WAITOK); + /* may have slept, have to check again */ + LIST_FOREACH(uip, uipp, ui_hash) + if (uip->ui_uid == uid) + break; + if (uip) { + free(nuip); + return (uip); + } + bzero(nuip, sizeof(*nuip)); + nuip->ui_uid = uid; + LIST_INSERT_HEAD(uipp, nuip, ui_hash); - return (uip); + return (nuip); } int |