History

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.

Dafna Hirschfeld committed 4 years ago

Commit ee1806b1 parent 05fd87b1 file · +8 −1Browse files

Showing the changes to include (1 of 1 file). Show all

Unified · Split

include/media/videobuf2-core.h+8−1
@@ -1155,8 +1155,15 @@ static inline void *vb2_get_drv_priv(struct vb2_queue *q) · 1154 unmodified lines
1155static inline void vb2_set_plane_payload(struct vb2_buffer *vb,1155static inline void vb2_set_plane_payload(struct vb2_buffer *vb,
1156 unsigned int plane_no, unsigned long size)1156 unsigned int plane_no, unsigned long size)
1157{1157{
1158 if (plane_no < vb->num_planes)1158 /*
1159 * size must never be larger than the buffer length, so
1160 * warn and clamp to the buffer length if that's the case.
1161 */
1162 if (plane_no < vb->num_planes) {
1163 if (WARN_ON_ONCE(size > vb->planes[plane_no].length))
1164 size = vb->planes[plane_no].length;
1159 vb->planes[plane_no].bytesused = size;1165 vb->planes[plane_no].bytesused = size;
1166 }
1160}1167}
1161 1168
1162/**1169/**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t