Commit 631794b4 authored by Patrik Jakobsson's avatar Patrik Jakobsson

drm/gma500: Lock struct_mutex around cursor updates

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=64361
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarPatrik Jakobsson <patrik.r.jakobsson@gmail.com>
parent a4ab86bc
...@@ -349,6 +349,7 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc, ...@@ -349,6 +349,7 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc,
/* If we didn't get a handle then turn the cursor off */ /* If we didn't get a handle then turn the cursor off */
if (!handle) { if (!handle) {
temp = CURSOR_MODE_DISABLE; temp = CURSOR_MODE_DISABLE;
mutex_lock(&dev->struct_mutex);
if (gma_power_begin(dev, false)) { if (gma_power_begin(dev, false)) {
REG_WRITE(control, temp); REG_WRITE(control, temp);
...@@ -365,6 +366,7 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc, ...@@ -365,6 +366,7 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc,
gma_crtc->cursor_obj = NULL; gma_crtc->cursor_obj = NULL;
} }
mutex_unlock(&dev->struct_mutex);
return 0; return 0;
} }
...@@ -374,9 +376,12 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc, ...@@ -374,9 +376,12 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc,
return -EINVAL; return -EINVAL;
} }
mutex_lock(&dev->struct_mutex);
obj = drm_gem_object_lookup(dev, file_priv, handle); obj = drm_gem_object_lookup(dev, file_priv, handle);
if (!obj) if (!obj) {
return -ENOENT; ret = -ENOENT;
goto unlock;
}
if (obj->size < width * height * 4) { if (obj->size < width * height * 4) {
dev_dbg(dev->dev, "Buffer is too small\n"); dev_dbg(dev->dev, "Buffer is too small\n");
...@@ -440,10 +445,13 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc, ...@@ -440,10 +445,13 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc,
} }
gma_crtc->cursor_obj = obj; gma_crtc->cursor_obj = obj;
unlock:
mutex_unlock(&dev->struct_mutex);
return ret; return ret;
unref_cursor: unref_cursor:
drm_gem_object_unreference(obj); drm_gem_object_unreference(obj);
mutex_unlock(&dev->struct_mutex);
return ret; return ret;
} }
......
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