Fix a problem in sys__lwp_create() where invalid new_lwp would
leak an LWP and memory. Reviewed by <ad>.
This commit is contained in:
parent
2f4c83c097
commit
9fe9a06d4b
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: sys_lwp.c,v 1.20 2007/06/03 09:50:12 dsl Exp $ */
|
||||
/* $NetBSD: sys_lwp.c,v 1.21 2007/07/11 00:17:23 rmind Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001, 2006, 2007 The NetBSD Foundation, Inc.
|
||||
@ -42,7 +42,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: sys_lwp.c,v 1.20 2007/06/03 09:50:12 dsl Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: sys_lwp.c,v 1.21 2007/07/11 00:17:23 rmind Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -115,6 +115,14 @@ sys__lwp_create(struct lwp *l, void *v, register_t *retval)
|
||||
return error;
|
||||
}
|
||||
|
||||
lid = l2->l_lid;
|
||||
error = copyout(&lid, SCARG(uap, new_lwp), sizeof(lid));
|
||||
if (error) {
|
||||
lwp_exit(l2);
|
||||
pool_put(&lwp_uc_pool, newuc);
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the new LWP running, unless the caller has requested that
|
||||
* it be created in suspended state. If the process is stopping,
|
||||
@ -122,7 +130,6 @@ sys__lwp_create(struct lwp *l, void *v, register_t *retval)
|
||||
*/
|
||||
mutex_enter(&p->p_smutex);
|
||||
lwp_lock(l2);
|
||||
lid = l2->l_lid;
|
||||
if ((SCARG(uap, flags) & LWP_SUSPENDED) == 0 &&
|
||||
(l->l_flag & (LW_WREBOOT | LW_WSUSPEND | LW_WEXIT)) == 0) {
|
||||
if (p->p_stat == SSTOP || (p->p_sflag & PS_STOPPING) != 0)
|
||||
@ -138,10 +145,6 @@ sys__lwp_create(struct lwp *l, void *v, register_t *retval)
|
||||
lwp_unlock(l2);
|
||||
mutex_exit(&p->p_smutex);
|
||||
|
||||
error = copyout(&lid, SCARG(uap, new_lwp), sizeof(lid));
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user