summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorRicardo Ribalda <ribalda@chromium.org>2021-10-07 01:26:18 +0300
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2021-10-08 14:27:07 +0300
commit37b198eeb0d41382d80b45101bac3a2e400e67a8 (patch)
tree735ad11ade26f60a72ee02e7945779be7716e842 /drivers
parentaf1ffd628adfb26f7dafe8e94e0f4bad99f44c3e (diff)
downloadlinux-37b198eeb0d41382d80b45101bac3a2e400e67a8.tar.xz
media: ipu3-cio2 Check num_planes and sizes in queue_setup
If num_planes is different than zero num_planes and sizes must be checked to support the format. Fix the following v4l2-compliance error: Buffer ioctls (Input 0): fail: v4l2-test-buffers.cpp(717): q.create_bufs(node, 1, &fmt) != EINVAL test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL Reviewed-by: Bingbu Cao <bingbu.cao@intel.com> Signed-off-by: Ricardo Ribalda <ribalda@chromium.org> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/pci/intel/ipu3/ipu3-cio2-main.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
index 98cb3bc834db..356ea966cf8d 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
@@ -797,13 +797,17 @@ static int cio2_vb2_queue_setup(struct vb2_queue *vq,
struct cio2_queue *q = vb2q_to_cio2_queue(vq);
unsigned int i;
- *num_planes = q->format.num_planes;
+ if (*num_planes && *num_planes < q->format.num_planes)
+ return -EINVAL;
- for (i = 0; i < *num_planes; ++i) {
+ for (i = 0; i < q->format.num_planes; ++i) {
+ if (*num_planes && sizes[i] < q->format.plane_fmt[i].sizeimage)
+ return -EINVAL;
sizes[i] = q->format.plane_fmt[i].sizeimage;
alloc_devs[i] = dev;
}
+ *num_planes = q->format.num_planes;
*num_buffers = clamp_val(*num_buffers, 1, CIO2_MAX_BUFFERS);
/* Initialize buffer queue */