video: tegra: nvmap: handle the vma->vm_mm NULL case
Krishna Reddy [Mon, 18 Sep 2017 18:00:27 +0000 (11:00 -0700)]
v4l2 is registering vma with vm_mm = NULL.

Bug 1874184

Change-Id: I24e61a531d9a506c7c146335240754931b3c238d
Signed-off-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1564203
Tested-by: Frank Shi <fshi@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Winnie Hsu <whsu@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

drivers/video/tegra/nvmap/nvmap_mm.c

index f5601b4..c3b9d2d 100644 (file)
@@ -223,6 +223,12 @@ static int nvmap_prot_handle(struct nvmap_handle *handle, u32 offset,
                struct vm_area_struct *prev;
 
                vma = vma_list->vma;
+               /* vm_mm = NULL for the vma_copy created in v4l2.
+                * ignore the kernel copy of vma. The protection fixing
+                * for user copy of vma is good enough.
+                */
+               if (!vma->vm_mm)
+                       continue;
                prev = vma->vm_prev;
                priv = vma->vm_private_data;
                if ((offset + size) > (vma->vm_end - vma->vm_start))