From 2dbd293c321ec3364decd255d07906406d9386ee Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 26 Jul 2010 17:16:45 +0100 Subject: [PATCH] drm: Warn if we attempt to free an active framebuffer object --- drivers/gpu/drm/drm_crtc.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index d9d5e9f..35227f7 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c @@ -1713,6 +1713,7 @@ int drm_mode_rmfb(struct drm_device *dev, struct drm_mode_object *obj; struct drm_framebuffer *fb = NULL; struct drm_framebuffer *fbl = NULL; + struct drm_crtc *crtc; uint32_t *id = data; int ret = 0; int found = 0; @@ -1737,7 +1738,16 @@ int drm_mode_rmfb(struct drm_device *dev, goto out; } - /* TODO release all crtc connected to the framebuffer */ + /* TODO release all crtc connected to the framebuffer. + * In the meantime, don't allow the user to break the kernel. + */ + list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { + if (crtc->fb == fb) { + DRM_ERROR("tried to remove an active fb\n"); + ret = -EBUSY; + goto out; + } + } /* TODO unhock the destructor from the buffer object */ list_del(&fb->filp_head); -- 1.7.1