Commit 0097ff8e authored by Sakari Ailus's avatar Sakari Ailus Committed by Mauro Carvalho Chehab

media: vb2: Enforce VB2_MAX_FRAME in vb2_core_reqbufs better

The check for the number of buffers requested against the maximum,
VB2_MAX_FRAME, was performed before checking queue's minimum number of
buffers. Reverse the order, thus ensuring that under no circumstances
num_buffers exceeds VB2_MAX_FRAME here.

Also add a warning of the condition.
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent df93dc61
...@@ -700,8 +700,9 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory, ...@@ -700,8 +700,9 @@ int vb2_core_reqbufs(struct vb2_queue *q, enum vb2_memory memory,
/* /*
* Make sure the requested values and current defaults are sane. * Make sure the requested values and current defaults are sane.
*/ */
num_buffers = min_t(unsigned int, *count, VB2_MAX_FRAME); WARN_ON(q->min_buffers_needed > VB2_MAX_FRAME);
num_buffers = max_t(unsigned int, num_buffers, q->min_buffers_needed); num_buffers = max_t(unsigned int, *count, q->min_buffers_needed);
num_buffers = min_t(unsigned int, num_buffers, VB2_MAX_FRAME);
memset(q->alloc_devs, 0, sizeof(q->alloc_devs)); memset(q->alloc_devs, 0, sizeof(q->alloc_devs));
q->memory = memory; q->memory = memory;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment