mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ricardo Ribalda <ribalda@chromium.org>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Yong Zhi <yong.zhi@intel.com>, Bingbu Cao <bingbu.cao@intel.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Chiranjeevi Rapolu <chiranjeevi.rapolu@intel.com>,
	Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Ricardo Ribalda <ribalda@chromium.org>
Subject: [PATCH v3 1/8] media: ipu3-cio2 Check num_planes and sizes in queue_setup
Date: Fri,  1 Oct 2021 11:25:15 +0000	[thread overview]
Message-ID: <20211001112522.2839602-2-ribalda@chromium.org> (raw)
In-Reply-To: <20211001112522.2839602-1-ribalda@chromium.org>

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>
---
 drivers/media/pci/intel/ipu3/ipu3-cio2-main.c | 8 ++++++--
 1 file 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 47db0ee0fcbfa..36099e95d29f2 100644
--- a/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2-main.c
@@ -798,13 +798,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] = &cio2->pci_dev->dev;
 	}
 
+	*num_planes = q->format.num_planes;
 	*num_buffers = clamp_val(*num_buffers, 1, CIO2_MAX_BUFFERS);
 
 	/* Initialize buffer queue */
-- 
2.33.0.800.g4c38ced690-goog


  reply	other threads:[~2021-10-01 11:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-01 11:25 [PATCH v3 0/8] media: ipu3 + i2c: Fix v4l2-compliance issues Ricardo Ribalda
2021-10-01 11:25 ` Ricardo Ribalda [this message]
2021-10-06 21:56   ` [PATCH v3 1/8] media: ipu3-cio2 Check num_planes and sizes in queue_setup Sakari Ailus
2021-10-06 22:27     ` Ricardo Ribalda
2021-10-01 11:25 ` [PATCH v3 2/8] media: ipu3-imgu: Refactor bytesperpixel calculation Ricardo Ribalda
2021-10-01 11:25 ` [PATCH v3 3/8] media: ipu3-imgu: Set valid initial format Ricardo Ribalda
2021-10-06 21:50   ` Sakari Ailus
2021-10-01 11:25 ` [PATCH v3 4/8] media: ipu3-imgu: imgu_fmt: Handle properly try Ricardo Ribalda
2021-10-01 11:25 ` [PATCH v3 5/8] media: ipu3-imgu: VIDIOC_QUERYCAP: Fix bus_info Ricardo Ribalda
2021-10-01 11:25 ` [PATCH v3 6/8] media: dw9714: Add implementation for events Ricardo Ribalda
2021-10-01 11:25 ` [PATCH v3 7/8] media: ov13858: " Ricardo Ribalda
2021-10-01 11:25 ` [PATCH v3 8/8] media: ov5670: " Ricardo Ribalda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211001112522.2839602-2-ribalda@chromium.org \
    --to=ribalda@chromium.org \
    --cc=bingbu.cao@intel.com \
    --cc=chiranjeevi.rapolu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=yong.zhi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®