Commit e94bd173 authored by Michel Dänzer's avatar Michel Dänzer Committed by Daniel Vetter

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: default avatarDmitry Vyukov <dvyukov@google.com>
Fixes: f837297a ("drm: Add DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE/RELATIVE flags v2")
Cc: stable@vger.kernel.org
Signed-off-by: default avatarMichel Dänzer <michel.daenzer@amd.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161130083002.1520-1-michel@daenzer.net
parent e5517c2a
...@@ -254,11 +254,13 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_ ...@@ -254,11 +254,13 @@ static int drm_getcap(struct drm_device *dev, void *data, struct drm_file *file_
req->value = dev->mode_config.async_page_flip; req->value = dev->mode_config.async_page_flip;
break; break;
case DRM_CAP_PAGE_FLIP_TARGET: case DRM_CAP_PAGE_FLIP_TARGET:
if (drm_core_check_feature(dev, DRIVER_MODESET)) {
req->value = 1; req->value = 1;
drm_for_each_crtc(crtc, dev) { drm_for_each_crtc(crtc, dev) {
if (!crtc->funcs->page_flip_target) if (!crtc->funcs->page_flip_target)
req->value = 0; req->value = 0;
} }
}
break; break;
case DRM_CAP_CURSOR_WIDTH: case DRM_CAP_CURSOR_WIDTH:
if (dev->mode_config.cursor_width) if (dev->mode_config.cursor_width)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment