Commit 487da617 authored by Daniel Stone's avatar Daniel Stone

drm: Reshuffle getfb error returns

Make it a little more clear what's going on inside of getfb, and also
make it easier to add alternate paths to get a handle in future.
Signed-off-by: default avatarDaniel Stone <daniels@collabora.com>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180323134553.15993-3-daniels@collabora.com
parent 83fd26c3
...@@ -468,29 +468,31 @@ int drm_mode_getfb(struct drm_device *dev, ...@@ -468,29 +468,31 @@ int drm_mode_getfb(struct drm_device *dev,
goto out; goto out;
} }
if (!fb->funcs->create_handle) {
ret = -ENODEV;
goto out;
}
r->height = fb->height; r->height = fb->height;
r->width = fb->width; r->width = fb->width;
r->depth = fb->format->depth; r->depth = fb->format->depth;
r->bpp = fb->format->cpp[0] * 8; r->bpp = fb->format->cpp[0] * 8;
r->pitch = fb->pitches[0]; r->pitch = fb->pitches[0];
if (fb->funcs->create_handle) {
if (drm_is_current_master(file_priv) || capable(CAP_SYS_ADMIN) || /* GET_FB() is an unprivileged ioctl so we must not return a
drm_is_control_client(file_priv)) { * buffer-handle to non-master processes! For
ret = fb->funcs->create_handle(fb, file_priv, * backwards-compatibility reasons, we cannot make GET_FB() privileged,
&r->handle); * so just return an invalid handle for non-masters.
} else { */
/* GET_FB() is an unprivileged ioctl so we must not if (!drm_is_current_master(file_priv) && !capable(CAP_SYS_ADMIN) &&
* return a buffer-handle to non-master processes! For !drm_is_control_client(file_priv)) {
* backwards-compatibility reasons, we cannot make r->handle = 0;
* GET_FB() privileged, so just return an invalid handle ret = 0;
* for non-masters. */ goto out;
r->handle = 0;
ret = 0;
}
} else {
ret = -ENODEV;
} }
ret = fb->funcs->create_handle(fb, file_priv, &r->handle);
out: out:
drm_framebuffer_put(fb); drm_framebuffer_put(fb);
......
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