]> Devi Nivas Git - cs3210-lab0.git/commitdiff
thanks mataness
authorFrans Kaashoek <kaashoek@mit.edu>
Thu, 30 Aug 2018 17:30:50 +0000 (13:30 -0400)
committerFrans Kaashoek <kaashoek@mit.edu>
Thu, 30 Aug 2018 17:30:50 +0000 (13:30 -0400)
vm.c

diff --git a/vm.c b/vm.c
index 3f71b6a7e3e2ea2feae2c268080793b4d0f83485..7134cfffbe2c088c0466f76faffbd35e424b151a 100644 (file)
--- a/vm.c
+++ b/vm.c
@@ -332,8 +332,10 @@ copyuvm(pde_t *pgdir, uint sz)
     if((mem = kalloc()) == 0)
       goto bad;
     memmove(mem, (char*)P2V(pa), PGSIZE);
-    if(mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0)
+    if(mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0) {
+      kfree(mem);
       goto bad;
+    }
   }
   return d;