Add a WARN_ON_ONCE in vb2_set_plane_payload if bytesused is bigger than length and clamp the bytesused to length. Also change places where bytesused is set directly with that function. This help find/eliminate possible buffer overflow. changes since v2: * Fix compilations issues on drivers/staging/media/meson/vdec/vdec_helpers.c * clamp the bytesused to the buffer length if it is bigger * update subject of second commit WARN_ON -> WARN_ON_ONCE changes since v1: * replace WARN_ON with WARN_ON_ONCE * add inline doc Dafna Hirschfeld (2): media: replace setting of bytesused with vb2_set_plane_payload media: videobuf2: add WARN_ON_ONCE if bytesused is bigger than buffer length drivers/media/platform/allegro-dvt/allegro-core.c | 2 +- drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 10 +++++----- drivers/media/test-drivers/vicodec/vicodec-core.c | 2 +- drivers/media/usb/go7007/go7007-driver.c | 2 +- drivers/staging/media/meson/vdec/vdec_helpers.c | 10 +++++----- include/media/videobuf2-core.h | 9 ++++++++- 6 files changed, 21 insertions(+), 14 deletions(-) -- 2.17.1