]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
gpu: nvgpu: mm: free allocations on validate error
authorShridhar Rasal <srasal@nvidia.com>
Tue, 22 Apr 2014 15:45:25 +0000 (21:15 +0530)
committerGerrit Code Review <gerrit2@nvidia.com>
Mon, 28 Apr 2014 05:50:22 +0000 (22:50 -0700)
Free allocated virtual address when marking PTE for validation
or update fails.

Bug 1479803

Change-Id: I9a8bd7c245b478f4252a261f246002fcc65d750d
Signed-off-by: Shridhar Rasal <srasal@nvidia.com>
drivers/gpu/nvgpu/gk20a/mm_gk20a.c

index 210fe1b3b147ac06277b4c73cfbc02ced62ff18c..18db19504fe6e54a68cd9942dc8a8548591320d4 100644 (file)
@@ -1104,6 +1104,7 @@ static u64 __locked_gmmu_map(struct vm_gk20a *vm,
                                int rw_flag)
 {
        int err = 0, i = 0;
+       bool allocated = false;
        u32 pde_lo, pde_hi;
        struct device *d = dev_from_vm(vm);
 
@@ -1114,8 +1115,9 @@ static u64 __locked_gmmu_map(struct vm_gk20a *vm,
                if (!map_offset) {
                        gk20a_err(d, "failed to allocate va space");
                        err = -ENOMEM;
-                       goto fail;
+                       goto fail_alloc;
                }
+               allocated = true;
        }
 
        pde_range_from_vaddr_range(vm,
@@ -1130,7 +1132,7 @@ static u64 __locked_gmmu_map(struct vm_gk20a *vm,
                if (err) {
                        gk20a_err(d, "failed to validate page table %d: %d",
                                                           i, err);
-                       goto fail;
+                       goto fail_validate;
                }
        }
 
@@ -1144,11 +1146,14 @@ static u64 __locked_gmmu_map(struct vm_gk20a *vm,
                                      rw_flag);
        if (err) {
                gk20a_err(d, "failed to update ptes on map");
-               goto fail;
+               goto fail_validate;
        }
 
        return map_offset;
- fail:
+fail_validate:
+       if (allocated)
+               gk20a_vm_free_va(vm, map_offset, size, pgsz_idx);
+fail_alloc:
        gk20a_err(d, "%s: failed with err=%d\n", __func__, err);
        return 0;
 }