summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/kern_proc.c22
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