diff options
Diffstat (limited to 'drivers/gpu/drm/drm_framebuffer.c')
-rw-r--r-- | drivers/gpu/drm/drm_framebuffer.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/gpu/drm/drm_framebuffer.c b/drivers/gpu/drm/drm_framebuffer.c index 3bf729d0aae5..fcaea8f50513 100644 --- a/drivers/gpu/drm/drm_framebuffer.c +++ b/drivers/gpu/drm/drm_framebuffer.c | |||
@@ -195,20 +195,26 @@ static int framebuffer_check(struct drm_device *dev, | |||
195 | for (i = 0; i < info->num_planes; i++) { | 195 | for (i = 0; i < info->num_planes; i++) { |
196 | unsigned int width = fb_plane_width(r->width, info, i); | 196 | unsigned int width = fb_plane_width(r->width, info, i); |
197 | unsigned int height = fb_plane_height(r->height, info, i); | 197 | unsigned int height = fb_plane_height(r->height, info, i); |
198 | unsigned int cpp = info->cpp[i]; | 198 | unsigned int block_size = info->char_per_block[i]; |
199 | u64 min_pitch = drm_format_info_min_pitch(info, i, width); | ||
200 | |||
201 | if (!block_size && (r->modifier[i] == DRM_FORMAT_MOD_LINEAR)) { | ||
202 | DRM_DEBUG_KMS("Format requires non-linear modifier for plane %d\n", i); | ||
203 | return -EINVAL; | ||
204 | } | ||
199 | 205 | ||
200 | if (!r->handles[i]) { | 206 | if (!r->handles[i]) { |
201 | DRM_DEBUG_KMS("no buffer object handle for plane %d\n", i); | 207 | DRM_DEBUG_KMS("no buffer object handle for plane %d\n", i); |
202 | return -EINVAL; | 208 | return -EINVAL; |
203 | } | 209 | } |
204 | 210 | ||
205 | if ((uint64_t) width * cpp > UINT_MAX) | 211 | if (min_pitch > UINT_MAX) |
206 | return -ERANGE; | 212 | return -ERANGE; |
207 | 213 | ||
208 | if ((uint64_t) height * r->pitches[i] + r->offsets[i] > UINT_MAX) | 214 | if ((uint64_t) height * r->pitches[i] + r->offsets[i] > UINT_MAX) |
209 | return -ERANGE; | 215 | return -ERANGE; |
210 | 216 | ||
211 | if (r->pitches[i] < width * cpp) { | 217 | if (block_size && r->pitches[i] < min_pitch) { |
212 | DRM_DEBUG_KMS("bad pitch %u for plane %d\n", r->pitches[i], i); | 218 | DRM_DEBUG_KMS("bad pitch %u for plane %d\n", r->pitches[i], i); |
213 | return -EINVAL; | 219 | return -EINVAL; |
214 | } | 220 | } |
@@ -317,6 +323,7 @@ drm_internal_framebuffer_create(struct drm_device *dev, | |||
317 | 323 | ||
318 | return fb; | 324 | return fb; |
319 | } | 325 | } |
326 | EXPORT_SYMBOL_FOR_TESTS_ONLY(drm_internal_framebuffer_create); | ||
320 | 327 | ||
321 | /** | 328 | /** |
322 | * drm_mode_addfb2 - add an FB to the graphics configuration | 329 | * drm_mode_addfb2 - add an FB to the graphics configuration |