Skip to content

Commit fa88dc7

Browse files
Hans Verkuilmchehab
authored andcommitted
media: dvb-core: add missing buffer index check
dvb_vb2_expbuf() didn't check if the given buffer index was for a valid buffer. Add this check. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Reported-by: Chenyuan Yang <chenyuan0y@gmail.com> Closes: https://lore.kernel.org/linux-media/?q=WARNING+in+vb2_core_reqbufs Fixes: 7dc866d ("media: dvb-core: Use vb2_get_buffer() instead of directly access to buffers array") Reviewed-by: Benjamin Gaignard <benjamin.gaignard@collabora.com> Cc: <stable@vger.kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent 9852d85 commit fa88dc7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/media/dvb-core/dvb_vb2.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,9 +366,15 @@ int dvb_vb2_querybuf(struct dvb_vb2_ctx *ctx, struct dmx_buffer *b)
366366
int dvb_vb2_expbuf(struct dvb_vb2_ctx *ctx, struct dmx_exportbuffer *exp)
367367
{
368368
struct vb2_queue *q = &ctx->vb_q;
369+
struct vb2_buffer *vb2 = vb2_get_buffer(q, exp->index);
369370
int ret;
370371

371-
ret = vb2_core_expbuf(&ctx->vb_q, &exp->fd, q->type, q->bufs[exp->index],
372+
if (!vb2) {
373+
dprintk(1, "[%s] invalid buffer index\n", ctx->name);
374+
return -EINVAL;
375+
}
376+
377+
ret = vb2_core_expbuf(&ctx->vb_q, &exp->fd, q->type, vb2,
372378
0, exp->flags);
373379
if (ret) {
374380
dprintk(1, "[%s] index=%d errno=%d\n", ctx->name,

0 commit comments

Comments
 (0)