commit ba04b3e70e4f1916c777d62de53088d96b09579f
parent dd645ef11911596d73d128c1da53579678c56aee
Author: Austin Clements <amdragon@mit.edu>
Date:   Wed,  1 Sep 2010 00:27:12 -0400
Fix similar leak in copyuvm
Diffstat:
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git 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