summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2018-11-08 07:23:37 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-01-09 17:46:02 +0100
commit314692da7ee9f7a0142182c7746ef60dd9797d5c (patch)
treeb1e0a70852a566597b354cac359040af7ec7dbc5
parent0f7b724295d50cb4da215428642b1724796342e2 (diff)
downloadlinux-314692da7ee9f7a0142182c7746ef60dd9797d5c.tar.gz
linux-314692da7ee9f7a0142182c7746ef60dd9797d5c.tar.bz2
linux-314692da7ee9f7a0142182c7746ef60dd9797d5c.zip
media: vb2: check memory model for VIDIOC_CREATE_BUFS
commit 62dcb4f41836bd3c44b5b651bb6df07ea4cb1551 upstream. vb2_core_create_bufs did not check if the memory model for newly added buffers is the same as for already existing buffers. It should return an error if they aren't the same. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Reported-by: syzbot+e1fb118a2ebb88031d21@syzkaller.appspotmail.com Cc: <stable@vger.kernel.org> # for v4.16 and up Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/media/common/videobuf2/videobuf2-core.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/media/common/videobuf2/videobuf2-core.c b/drivers/media/common/videobuf2/videobuf2-core.c
index 8ff8722cb6b1..99f736c81286 100644
--- a/drivers/media/common/videobuf2/videobuf2-core.c
+++ b/drivers/media/common/videobuf2/videobuf2-core.c
@@ -812,6 +812,9 @@ int vb2_core_create_bufs(struct vb2_queue *q, enum vb2_memory memory,
memset(q->alloc_devs, 0, sizeof(q->alloc_devs));
q->memory = memory;
q->waiting_for_buffers = !q->is_output;
+ } else if (q->memory != memory) {
+ dprintk(1, "memory model mismatch\n");
+ return -EINVAL;
}
num_buffers = min(*count, VB2_MAX_FRAME - q->num_buffers);