In function vb2_set_plane_payload, report if the given bytesused is bigger than the buffer size, and clamp it to the buffer size.
Showing the changes to include (1 of 1 file). Show all
Unified · Split
| @@ -1155,8 +1155,15 @@ static inline void *vb2_get_drv_priv(struct vb2_queue *q) · 1154 unmodified lines | |||
| 1155 | static inline void vb2_set_plane_payload(struct vb2_buffer *vb, | 1155 | static 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 | /** |