From: Seung-Woo Kim Date: Fri, 12 Apr 2013 02:57:57 +0000 (-0300) Subject: [media] media: vb2: add length check for mmap X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=068a0df76023926af958a336a78bef60468d2033;p=openwrt%2Fstaging%2Fblogic.git [media] media: vb2: add length check for mmap The length of mmap() can be bigger than length of vb2 buffer, so it should be checked. Signed-off-by: Seung-Woo Kim Acked-by: Marek Szyprowski Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/v4l2-core/videobuf2-core.c b/drivers/media/v4l2-core/videobuf2-core.c index 02bb5e721657..58c17444d22f 100644 --- a/drivers/media/v4l2-core/videobuf2-core.c +++ b/drivers/media/v4l2-core/videobuf2-core.c @@ -1886,6 +1886,11 @@ int vb2_mmap(struct vb2_queue *q, struct vm_area_struct *vma) vb = q->bufs[buffer]; + if (vb->v4l2_planes[plane].length < (vma->vm_end - vma->vm_start)) { + dprintk(1, "Invalid length\n"); + return -EINVAL; + } + ret = call_memop(q, mmap, vb->planes[plane].mem_priv, vma); if (ret) return ret;