Commit 2c06aa7c authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

media: dvb_vb2: limit reqbufs size to a sane value

It is not a good idea to let users to request a very high buffer
size.

So, add an upper limit.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 7b6c96d5
...@@ -18,6 +18,8 @@ ...@@ -18,6 +18,8 @@
#include "dvbdev.h" #include "dvbdev.h"
#include "dvb_vb2.h" #include "dvb_vb2.h"
#define DVB_V2_MAX_SIZE (4096 * 188)
static int vb2_debug; static int vb2_debug;
module_param(vb2_debug, int, 0644); module_param(vb2_debug, int, 0644);
...@@ -330,6 +332,12 @@ int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req) ...@@ -330,6 +332,12 @@ int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req)
{ {
int ret; int ret;
/* Adjust size to a sane value */
if (req->size > DVB_V2_MAX_SIZE)
req->size = DVB_V2_MAX_SIZE;
/* FIXME: round req->size to a 188 or 204 multiple */
ctx->buf_siz = req->size; ctx->buf_siz = req->size;
ctx->buf_cnt = req->count; ctx->buf_cnt = req->count;
ret = vb2_core_reqbufs(&ctx->vb_q, VB2_MEMORY_MMAP, &req->count); ret = vb2_core_reqbufs(&ctx->vb_q, VB2_MEMORY_MMAP, &req->count);
......
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