media: videobuf2: Explicitly state max size of planes
authorRicardo Ribalda <ribalda@chromium.org>
Wed, 10 Mar 2021 10:46:39 +0000 (11:46 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 22 Mar 2021 10:51:44 +0000 (11:51 +0100)
The plane size needs to be PAGE_ALIGNED, so it is not possible to have
sizes bigger than MAX_INT - PAGE_SIZE.

We already check for overflows when that happen:
 if (size < vb->planes[plane].length)
goto free;

But it is good to explicitly state our max allowed value, in order to
align with the driver expectations.

Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
include/media/videobuf2-core.h

index 799ba61b5b6f3cfd705fa1b83ca29dc7d4b9f14f..12955cb460d2348e9479ca979d3bd388fefb580d 100644 (file)
@@ -154,9 +154,11 @@ struct vb2_mem_ops {
  * @dbuf:      dma_buf - shared buffer object.
  * @dbuf_mapped:       flag to show whether dbuf is mapped or not
  * @bytesused: number of bytes occupied by data in the plane (payload).
- * @length:    size of this plane (NOT the payload) in bytes.
+ * @length:    size of this plane (NOT the payload) in bytes. The maximum
+ *             valid size is MAX_UINT - PAGE_SIZE.
  * @min_length:        minimum required size of this plane (NOT the payload) in bytes.
- *             @length is always greater or equal to @min_length.
+ *             @length is always greater or equal to @min_length, and like
+ *             @length, it is limited to MAX_UINT - PAGE_SIZE.
  * @m:         Union with memtype-specific data.
  * @m.offset:  when memory in the associated struct vb2_buffer is
  *             %VB2_MEMORY_MMAP, equals the offset from the start of