Skip to content

Commit e94bd17

Browse files
Michel Dänzerdanvet
authored andcommitted
drm: Don't call drm_for_each_crtc with a non-KMS driver
Fixes oops if userspace calls DRM_IOCTL_GET_CAP for DRM_CAP_PAGE_FLIP_TARGET on a non-KMS device node. (Normal userspace doesn't do that, discovered by syzkaller) Reported-by: Dmitry Vyukov <[email protected]> Fixes: f837297 ("drm: Add DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE/RELATIVE flags v2") Cc: [email protected] Signed-off-by: Michel Dänzer <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent e5517c2 commit e94bd17

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/gpu/drm/drm_ioctl.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,12 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
254254
req->value = dev->mode_config.async_page_flip;
255255
break;
256256
case DRM_CAP_PAGE_FLIP_TARGET:
257-
req->value = 1;
258-
drm_for_each_crtc(crtc, dev) {
259-
if (!crtc->funcs->page_flip_target)
260-
req->value = 0;
257+
if (drm_core_check_feature(dev, DRIVER_MODESET)) {
258+
req->value = 1;
259+
drm_for_each_crtc(crtc, dev) {
260+
if (!crtc->funcs->page_flip_target)
261+
req->value = 0;
262+
}
261263
}
262264
break;
263265
case DRM_CAP_CURSOR_WIDTH:

0 commit comments

Comments
 (0)