media: videobuf2: add WARN_ON_ONCE if bytesused is bigger than buffer length
In function vb2_set_plane_payload, report if the given bytesused is bigger than the buffer size, and clamp it to the buffer size. Signed-off-by: Dafna Hirschfeld <dafna.hirschfeld@collabora.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
parent
05fd87b8d9
commit
ee1806beff
|
@ -1155,9 +1155,16 @@ static inline void *vb2_get_drv_priv(struct vb2_queue *q)
|
||||||
static inline void vb2_set_plane_payload(struct vb2_buffer *vb,
|
static inline void vb2_set_plane_payload(struct vb2_buffer *vb,
|
||||||
unsigned int plane_no, unsigned long size)
|
unsigned int plane_no, unsigned long size)
|
||||||
{
|
{
|
||||||
if (plane_no < vb->num_planes)
|
/*
|
||||||
|
* size must never be larger than the buffer length, so
|
||||||
|
* warn and clamp to the buffer length if that's the case.
|
||||||
|
*/
|
||||||
|
if (plane_no < vb->num_planes) {
|
||||||
|
if (WARN_ON_ONCE(size > vb->planes[plane_no].length))
|
||||||
|
size = vb->planes[plane_no].length;
|
||||||
vb->planes[plane_no].bytesused = size;
|
vb->planes[plane_no].bytesused = size;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vb2_get_plane_payload() - get bytesused for the plane plane_no
|
* vb2_get_plane_payload() - get bytesused for the plane plane_no
|
||||||
|
|
Loading…
Reference in New Issue