[media] v4l: vb2-dma-contig: fix vb2_get_vma()
Sri Krishna chowdary [Tue, 12 Jan 2016 10:24:08 +0000 (15:24 +0530)]
nvmap expects that same VMA is opened and closed to disallow
memory leaks. So, nvmap panics if a previously non-existent vma
is being closed through it.

Hence modify the sequence in vb2_get_vma() to
open the vma_copy before returning it. This way nvmap sees that
the vma_copy exists in its list and will close the vma.

Bug 200164002

Change-Id: I45dfb8ca710375a0e70d9802ebdcc9fd4d0b4600
Signed-off-by: Sri Krishna chowdary <schowdary@nvidia.com>
Reviewed-on: http://git-master/r/931997
(cherry picked from commit bf1d15d8a879a599f9801310cecbbb61ea60e931)
Reviewed-on: http://git-master/r/1133707
Tested-by: Bryan Wu <pengw@nvidia.com>
Reviewed-by: Bryan Wu <pengw@nvidia.com>
Reviewed-by: Krishna Reddy <vdumpa@nvidia.com>
Reviewed-by: Matthew Pedro <mapedro@nvidia.com>

drivers/media/v4l2-core/videobuf2-memops.c

index 81c1ad8..a8099ba 100644 (file)
@@ -49,6 +49,12 @@ struct vm_area_struct *vb2_get_vma(struct vm_area_struct *vma)
 
        memcpy(vma_copy, vma, sizeof(*vma));
 
+       if (vma_copy->vm_ops && vma_copy->vm_ops->open)
+               vma_copy->vm_ops->open(vma_copy);
+
+       if (vma->vm_ops && vma->vm_ops->close)
+               vma->vm_ops->close(vma);
+
        vma_copy->vm_mm = NULL;
        vma_copy->vm_next = NULL;
        vma_copy->vm_prev = NULL;