sys__lwp_create: put newuc back to the pool on failure.

This commit is contained in:
ad 2006-08-14 14:11:21 +00:00
parent 7db024f8e7
commit 87dd042f7a

View File

@ -1,4 +1,4 @@
/* $NetBSD: kern_lwp.c,v 1.39 2006/07/30 21:58:11 ad Exp $ */
/* $NetBSD: kern_lwp.c,v 1.40 2006/08/14 14:11:21 ad Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.39 2006/07/30 21:58:11 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.40 2006/08/14 14:11:21 ad Exp $");
#include "opt_multiprocessor.h"
@ -90,13 +90,16 @@ sys__lwp_create(struct lwp *l, void *v, register_t *retval)
error = copyin(SCARG(uap, ucp), newuc,
l->l_proc->p_emul->e_sa->sae_ucsize);
if (error)
if (error) {
pool_put(&lwp_uc_pool, newuc);
return (error);
}
/* XXX check against resource limits */
inmem = uvm_uarea_alloc(&uaddr);
if (__predict_false(uaddr == 0)) {
pool_put(&lwp_uc_pool, newuc);
return (ENOMEM);
}
@ -120,8 +123,10 @@ sys__lwp_create(struct lwp *l, void *v, register_t *retval)
error = copyout(&l2->l_lid, SCARG(uap, new_lwp),
sizeof(l2->l_lid));
if (error)
if (error) {
/* XXX We should destroy the LWP. */
return (error);
}
return (0);
}