Commit 75df6247 authored by Chris Wilson's avatar Chris Wilson Committed by Daniel Vetter

drm: Use u64_to_user_ptr() helper for blob ioctls

Remove the ugly sparse casts by using the helper u64_to_user_ptr()
instead.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161127170910.29106-1-chris@chris-wilson.co.uk
parent 8b2fb7b6
...@@ -729,7 +729,6 @@ int drm_mode_getblob_ioctl(struct drm_device *dev, ...@@ -729,7 +729,6 @@ int drm_mode_getblob_ioctl(struct drm_device *dev,
struct drm_mode_get_blob *out_resp = data; struct drm_mode_get_blob *out_resp = data;
struct drm_property_blob *blob; struct drm_property_blob *blob;
int ret = 0; int ret = 0;
void __user *blob_ptr;
if (!drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_MODESET))
return -EINVAL; return -EINVAL;
...@@ -739,8 +738,9 @@ int drm_mode_getblob_ioctl(struct drm_device *dev, ...@@ -739,8 +738,9 @@ int drm_mode_getblob_ioctl(struct drm_device *dev,
return -ENOENT; return -ENOENT;
if (out_resp->length == blob->length) { if (out_resp->length == blob->length) {
blob_ptr = (void __user *)(unsigned long)out_resp->data; if (copy_to_user(u64_to_user_ptr(out_resp->data),
if (copy_to_user(blob_ptr, blob->data, blob->length)) { blob->data,
blob->length)) {
ret = -EFAULT; ret = -EFAULT;
goto unref; goto unref;
} }
...@@ -757,7 +757,6 @@ int drm_mode_createblob_ioctl(struct drm_device *dev, ...@@ -757,7 +757,6 @@ int drm_mode_createblob_ioctl(struct drm_device *dev,
{ {
struct drm_mode_create_blob *out_resp = data; struct drm_mode_create_blob *out_resp = data;
struct drm_property_blob *blob; struct drm_property_blob *blob;
void __user *blob_ptr;
int ret = 0; int ret = 0;
if (!drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_MODESET))
...@@ -767,8 +766,9 @@ int drm_mode_createblob_ioctl(struct drm_device *dev, ...@@ -767,8 +766,9 @@ int drm_mode_createblob_ioctl(struct drm_device *dev,
if (IS_ERR(blob)) if (IS_ERR(blob))
return PTR_ERR(blob); return PTR_ERR(blob);
blob_ptr = (void __user *)(unsigned long)out_resp->data; if (copy_from_user(blob->data,
if (copy_from_user(blob->data, blob_ptr, out_resp->length)) { u64_to_user_ptr(out_resp->data),
out_resp->length)) {
ret = -EFAULT; ret = -EFAULT;
goto out_blob; goto out_blob;
} }
......
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