From: Michael Jones <michael.jones@matrix-vision.de>
Date: Tue, 9 Aug 2011 06:42:20 +0000 (+0200)
Subject: [media] omap3isp: queue: fail QBUF if user buffer is too small
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=61e6561fae573c3c618118a71ff966ddb14299da;p=GitHub%2FLineageOS%2FG12%2Fandroid_kernel_amlogic_linux-4.9.git

[media] omap3isp: queue: fail QBUF if user buffer is too small

Add buffer length check to sanity checks for USERPTR QBUF.

Signed-off-by: Michael Jones <michael.jones@matrix-vision.de>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---

diff --git a/drivers/media/video/omap3isp/ispqueue.c b/drivers/media/video/omap3isp/ispqueue.c
index 9c317148205f..9bebb1e57aab 100644
--- a/drivers/media/video/omap3isp/ispqueue.c
+++ b/drivers/media/video/omap3isp/ispqueue.c
@@ -867,6 +867,10 @@ int omap3isp_video_queue_qbuf(struct isp_video_queue *queue,
 	if (buf->state != ISP_BUF_STATE_IDLE)
 		goto done;
 
+	if (vbuf->memory == V4L2_MEMORY_USERPTR &&
+	    vbuf->length < buf->vbuf.length)
+		goto done;
+
 	if (vbuf->memory == V4L2_MEMORY_USERPTR &&
 	    vbuf->m.userptr != buf->vbuf.m.userptr) {
 		isp_video_buffer_cleanup(buf);