From ba04b3e70e4f1916c777d62de53088d96b09579f Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Wed, 1 Sep 2010 00:27:12 -0400 Subject: [PATCH] Fix similar leak in copyuvm --- vm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/vm.c b/vm.c index 95eeca8..a60c915 100644 --- a/vm.c +++ b/vm.c @@ -313,13 +313,17 @@ copyuvm(pde_t *pgdir, uint sz) if(*pte & PTE_P){ pa = PTE_ADDR(*pte); if (!(mem = kalloc())) - return 0; + goto bad; memmove(mem, (char *)pa, PGSIZE); if (!mappages(d, (void *)i, PGSIZE, PADDR(mem), PTE_W|PTE_U)) - return 0; + goto bad; } } return d; + +bad: + freevm(d); + return 0; } // Allocate one page table for the machine for the kernel address