diff options
author | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-12-28 07:11:40 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2017-12-28 11:17:27 -0500 |
commit | 2c06aa7c31cfad2b95e298e55075b962b7e4dc2b (patch) | |
tree | c8d17f2da39ea27d2f13825ed2f922fd33b8b0af /drivers/media/dvb-core | |
parent | 7b6c96d59e43802e846011179e040646a159905e (diff) |
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: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/dvb-core')
-rw-r--r-- | drivers/media/dvb-core/dvb_vb2.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/media/dvb-core/dvb_vb2.c b/drivers/media/dvb-core/dvb_vb2.c index 36313387d8b2..4223d33c60dc 100644 --- a/drivers/media/dvb-core/dvb_vb2.c +++ b/drivers/media/dvb-core/dvb_vb2.c @@ -18,6 +18,8 @@ #include "dvbdev.h" #include "dvb_vb2.h" +#define DVB_V2_MAX_SIZE (4096 * 188) + static int vb2_debug; module_param(vb2_debug, int, 0644); @@ -330,6 +332,12 @@ int dvb_vb2_reqbufs(struct dvb_vb2_ctx *ctx, struct dmx_requestbuffers *req) { 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_cnt = req->count; ret = vb2_core_reqbufs(&ctx->vb_q, VB2_MEMORY_MMAP, &req->count); |