diff options
| author | yamt <yamt@NetBSD.org> | 2008-01-07 11:41:29 +0000 |
|---|---|---|
| committer | yamt <yamt@NetBSD.org> | 2008-01-07 11:41:29 +0000 |
| commit | 2e8a5bee6869b36db2cf73bc39123dbaf1bed731 (patch) | |
| tree | 36fcbe64d79d71ae93a3dcccdfdf2d549dc0d2bb | |
| parent | cfde7482cd4954b0ddc2d2f1e98b86a908c29002 (diff) | |
lwp_ctl_alloc: fix error handling.
| -rw-r--r-- | sys/kern/kern_lwp.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/sys/kern/kern_lwp.c b/sys/kern/kern_lwp.c index 826f00a258e..6e14e6f38ce 100644 --- a/sys/kern/kern_lwp.c +++ b/sys/kern/kern_lwp.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_lwp.c,v 1.88 2008/01/02 11:48:50 ad Exp $ */ +/* $NetBSD: kern_lwp.c,v 1.89 2008/01/07 11:41:29 yamt Exp $ */ /*- * Copyright (c) 2001, 2006, 2007 The NetBSD Foundation, Inc. @@ -205,7 +205,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.88 2008/01/02 11:48:50 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.89 2008/01/07 11:41:29 yamt Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -1515,15 +1515,21 @@ lwp_ctl_alloc(vaddr_t *uaddr) uao, lp->lp_cur, PAGE_SIZE, UVM_MAPFLAG(UVM_PROT_RW, UVM_PROT_RW, UVM_INH_NONE, UVM_ADV_RANDOM, 0)); - if (error == 0) - error = uvm_map_pageable(kernel_map, lcp->lcp_kaddr, - lcp->lcp_kaddr + PAGE_SIZE, FALSE, 0); if (error != 0) { mutex_exit(&lp->lp_lock); kmem_free(lcp, LWPCTL_LCPAGE_SZ); (*uao->pgops->pgo_detach)(uao); return error; } + error = uvm_map_pageable(kernel_map, lcp->lcp_kaddr, + lcp->lcp_kaddr + PAGE_SIZE, FALSE, 0); + if (error != 0) { + mutex_exit(&lp->lp_lock); + uvm_unmap(kernel_map, lcp->lcp_kaddr, + lcp->lcp_kaddr + PAGE_SIZE); + kmem_free(lcp, LWPCTL_LCPAGE_SZ); + return error; + } /* Prepare the page descriptor and link into the list. */ lcp->lcp_uaddr = lp->lp_uva + lp->lp_cur; lp->lp_cur += PAGE_SIZE; |
