]> 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)
committerRiham Haidar <rhaidar@nvidia.com>
Wed, 28 May 2014 01:46:03 +0000 (18:46 -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>
(cherry picked from commit b5c0ad4e00dfc86b65e8efe3d8691b5cfaafbe4c)
Reviewed-on: http://git-master/r/415248
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
drivers/gpu/nvgpu/gk20a/mm_gk20a.c

index 9de589f9d6e2942ca5e9640f1b545475d93c5f77..af7e0b512f5ee1d8fd38bc909d91a13b0ad70db8 100644 (file)
@@ -1103,6 +1103,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);
 
@@ -1113,8 +1114,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,
@@ -1129,7 +1131,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;
                }
        }
 
@@ -1143,11 +1145,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;
 }