diff options
author | Sakari Ailus <sakari.ailus@linux.intel.com> | 2017-12-28 17:18:20 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2018-01-03 12:56:38 +0300 |
commit | 0097ff8e3ea0a737ee3c528ab7c85c35bef78e28 (patch) | |
tree | cafe447a026b2a771239359ecfda793662debabc /drivers/media/common | |
parent | df93dc61b0d8b19a5c9db545cf3fcc24f88dfde4 (diff) | |
download | linux-0097ff8e3ea0a737ee3c528ab7c85c35bef78e28.tar.xz |
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: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/common')
-rw-r--r-- | drivers/media/common/videobuf/videobuf2-core.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/media/common/videobuf/videobuf2-core.c b/drivers/media/common/videobuf/videobuf2-core.c index dbb0fd8e304f..365b30c55ead 100644 --- a/drivers/media/common/videobuf/videobuf2-core.c +++ b/drivers/media/common/videobuf/videobuf2-core.c @@ -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. */ - num_buffers = min_t(unsigned int, *count, VB2_MAX_FRAME); - num_buffers = max_t(unsigned int, num_buffers, q->min_buffers_needed); + WARN_ON(q->min_buffers_needed > VB2_MAX_FRAME); + 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)); q->memory = memory; |