Remove the ugly sparse casts by using the helper u64_to_user_ptr() instead.
Signed-off-by: Chris Wilson chris@chris-wilson.co.uk --- drivers/gpu/drm/drm_property.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/drm_property.c b/drivers/gpu/drm/drm_property.c index d1e50ac6f72b..24be69d29964 100644 --- a/drivers/gpu/drm/drm_property.c +++ b/drivers/gpu/drm/drm_property.c @@ -729,7 +729,6 @@ int drm_mode_getblob_ioctl(struct drm_device *dev, struct drm_mode_get_blob *out_resp = data; struct drm_property_blob *blob; int ret = 0; - void __user *blob_ptr;
if (!drm_core_check_feature(dev, DRIVER_MODESET)) return -EINVAL; @@ -739,8 +738,9 @@ int drm_mode_getblob_ioctl(struct drm_device *dev, return -ENOENT;
if (out_resp->length == blob->length) { - blob_ptr = (void __user *)(unsigned long)out_resp->data; - if (copy_to_user(blob_ptr, blob->data, blob->length)) { + if (copy_to_user(u64_to_user_ptr(out_resp->data), + blob->data, + blob->length)) { ret = -EFAULT; goto unref; } @@ -757,7 +757,6 @@ int drm_mode_createblob_ioctl(struct drm_device *dev, { struct drm_mode_create_blob *out_resp = data; struct drm_property_blob *blob; - void __user *blob_ptr; int ret = 0;
if (!drm_core_check_feature(dev, DRIVER_MODESET)) @@ -767,8 +766,9 @@ int drm_mode_createblob_ioctl(struct drm_device *dev, if (IS_ERR(blob)) return PTR_ERR(blob);
- blob_ptr = (void __user *)(unsigned long)out_resp->data; - if (copy_from_user(blob->data, blob_ptr, out_resp->length)) { + if (copy_from_user(blob->data, + u64_to_user_ptr(out_resp->data), + out_resp->length)) { ret = -EFAULT; goto out_blob; }
smatch warns:
drivers/gpu/drm/drm_lock.c:188 drm_legacy_lock() warn: variable dereferenced before check 'master->lock.hw_lock' (see line 177)
Signed-off-by: Chris Wilson chris@chris-wilson.co.uk --- drivers/gpu/drm/drm_lock.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c index c901f3c5b269..32d43f86a8f2 100644 --- a/drivers/gpu/drm/drm_lock.c +++ b/drivers/gpu/drm/drm_lock.c @@ -176,7 +176,8 @@ int drm_legacy_lock(struct drm_device *dev, void *data,
DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", lock->context, task_pid_nr(current), - master->lock.hw_lock->lock, lock->flags); + master->lock.hw_lock ? master->lock.hw_lock->lock : -1, + lock->flags);
add_wait_queue(&master->lock.lock_queue, &entry); spin_lock_bh(&master->lock.spinlock);
smatch correctly warns:
drivers/gpu/drm/drm_fb_helper.c:1960 drm_target_preferred() warn: should '1 << i' be a 64 bit type? drivers/gpu/drm/drm_fb_helper.c:2001 drm_target_preferred() warn: should '1 << i' be a 64 bit type?
Signed-off-by: Chris Wilson chris@chris-wilson.co.uk --- drivers/gpu/drm/drm_fb_helper.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 851a7e30444b..3a71a03b14a9 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -1945,19 +1945,20 @@ static bool drm_target_preferred(struct drm_fb_helper *fb_helper, bool *enabled, int width, int height) { struct drm_fb_helper_connector *fb_helper_conn; - int i; - uint64_t conn_configured = 0, mask; + const u64 mask = BIT_ULL(fb_helper->connector_count) - 1; + u64 conn_configured = 0; int tile_pass = 0; - mask = (1 << fb_helper->connector_count) - 1; + int i; + retry: drm_fb_helper_for_each_connector(fb_helper, i) { fb_helper_conn = fb_helper->connector_info[i];
- if (conn_configured & (1 << i)) + if (conn_configured & BIT_ULL(i)) continue;
if (enabled[i] == false) { - conn_configured |= (1 << i); + conn_configured |= BIT_ULL(i); continue; }
@@ -1998,7 +1999,7 @@ static bool drm_target_preferred(struct drm_fb_helper *fb_helper, } DRM_DEBUG_KMS("found mode %s\n", modes[i] ? modes[i]->name : "none"); - conn_configured |= (1 << i); + conn_configured |= BIT_ULL(i); }
if ((conn_configured & mask) != mask) {
On Sun, Nov 27, 2016 at 05:09:10PM +0000, Chris Wilson wrote:
smatch correctly warns:
drivers/gpu/drm/drm_fb_helper.c:1960 drm_target_preferred() warn: should '1 << i' be a 64 bit type? drivers/gpu/drm/drm_fb_helper.c:2001 drm_target_preferred() warn: should '1 << i' be a 64 bit type?
Signed-off-by: Chris Wilson chris@chris-wilson.co.uk
Entire series applied, thx. -Daniel
drivers/gpu/drm/drm_fb_helper.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 851a7e30444b..3a71a03b14a9 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -1945,19 +1945,20 @@ static bool drm_target_preferred(struct drm_fb_helper *fb_helper, bool *enabled, int width, int height) { struct drm_fb_helper_connector *fb_helper_conn;
- int i;
- uint64_t conn_configured = 0, mask;
- const u64 mask = BIT_ULL(fb_helper->connector_count) - 1;
- u64 conn_configured = 0; int tile_pass = 0;
- mask = (1 << fb_helper->connector_count) - 1;
- int i;
retry: drm_fb_helper_for_each_connector(fb_helper, i) { fb_helper_conn = fb_helper->connector_info[i];
if (conn_configured & (1 << i))
if (conn_configured & BIT_ULL(i)) continue;
if (enabled[i] == false) {
conn_configured |= (1 << i);
}conn_configured |= BIT_ULL(i); continue;
@@ -1998,7 +1999,7 @@ static bool drm_target_preferred(struct drm_fb_helper *fb_helper, } DRM_DEBUG_KMS("found mode %s\n", modes[i] ? modes[i]->name : "none");
conn_configured |= (1 << i);
conn_configured |= BIT_ULL(i);
}
if ((conn_configured & mask) != mask) {
-- 2.10.2
Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
On su, 2016-11-27 at 17:09 +0000, Chris Wilson wrote:
smatch correctly warns:
drivers/gpu/drm/drm_fb_helper.c:1960 drm_target_preferred() warn: should '1 << i' be a 64 bit type? drivers/gpu/drm/drm_fb_helper.c:2001 drm_target_preferred() warn: should '1 << i' be a 64 bit type?
Signed-off-by: Chris Wilson chris@chris-wilson.co.uk
Reviewed-by: Joonas Lahtinen joonas.lahtinen@linux.intel.com
Regards, Joonas
On su, 2016-11-27 at 17:09 +0000, Chris Wilson wrote:
Remove the ugly sparse casts by using the helper u64_to_user_ptr() instead.
Signed-off-by: Chris Wilson chris@chris-wilson.co.uk
Reviewed-by: Joonas Lahtinen joonas.lahtinen@linux.intel.com
Regards, Joonas
dri-devel@lists.freedesktop.org