All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] drm: Use u64_to_user_ptr() helper for blob ioctls
@ 2016-11-27 17:09 Chris Wilson
  2016-11-27 17:09 ` [PATCH 2/3] drm: Avoid NULL dereference for DRM_LEGACY debug message Chris Wilson
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Chris Wilson @ 2016-11-27 17:09 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

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;
 	}
-- 
2.10.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] drm: Avoid NULL dereference for DRM_LEGACY debug message
  2016-11-27 17:09 [PATCH 1/3] drm: Use u64_to_user_ptr() helper for blob ioctls Chris Wilson
@ 2016-11-27 17:09 ` Chris Wilson
  2016-11-27 17:09 ` [PATCH 3/3] drm: Fix shift operations for drm_fb_helper::drm_target_preferred() Chris Wilson
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Chris Wilson @ 2016-11-27 17:09 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

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);
-- 
2.10.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] drm: Fix shift operations for drm_fb_helper::drm_target_preferred()
  2016-11-27 17:09 [PATCH 1/3] drm: Use u64_to_user_ptr() helper for blob ioctls Chris Wilson
  2016-11-27 17:09 ` [PATCH 2/3] drm: Avoid NULL dereference for DRM_LEGACY debug message Chris Wilson
@ 2016-11-27 17:09 ` Chris Wilson
  2016-11-28  7:18   ` [Intel-gfx] " Daniel Vetter
  2016-11-28  8:18   ` Joonas Lahtinen
  2016-11-27 17:45 ` ✗ Fi.CI.BAT: warning for series starting with [1/3] drm: Use u64_to_user_ptr() helper for blob ioctls Patchwork
  2016-11-28  7:06 ` [Intel-gfx] [PATCH 1/3] " Joonas Lahtinen
  3 siblings, 2 replies; 7+ messages in thread
From: Chris Wilson @ 2016-11-27 17:09 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

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) {
-- 
2.10.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* ✗ Fi.CI.BAT: warning for series starting with [1/3] drm: Use u64_to_user_ptr() helper for blob ioctls
  2016-11-27 17:09 [PATCH 1/3] drm: Use u64_to_user_ptr() helper for blob ioctls Chris Wilson
  2016-11-27 17:09 ` [PATCH 2/3] drm: Avoid NULL dereference for DRM_LEGACY debug message Chris Wilson
  2016-11-27 17:09 ` [PATCH 3/3] drm: Fix shift operations for drm_fb_helper::drm_target_preferred() Chris Wilson
@ 2016-11-27 17:45 ` Patchwork
  2016-11-28  7:06 ` [Intel-gfx] [PATCH 1/3] " Joonas Lahtinen
  3 siblings, 0 replies; 7+ messages in thread
From: Patchwork @ 2016-11-27 17:45 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/3] drm: Use u64_to_user_ptr() helper for blob ioctls
URL   : https://patchwork.freedesktop.org/series/16000/
State : warning

== Summary ==

Series 16000v1 Series without cover letter
https://patchwork.freedesktop.org/api/1.0/series/16000/revisions/1/mbox/

Test gem_exec_flush:
        Subgroup basic-uc-set-default:
                pass       -> DMESG-WARN (fi-snb-2520m)
Test kms_force_connector_basic:
        Subgroup force-load-detect:
                dmesg-warn -> PASS       (fi-snb-2520m)

fi-bdw-5557u     total:245  pass:230  dwarn:0   dfail:0   fail:0   skip:15 
fi-bsw-n3050     total:245  pass:205  dwarn:0   dfail:0   fail:0   skip:40 
fi-bxt-t5700     total:245  pass:217  dwarn:0   dfail:0   fail:0   skip:28 
fi-byt-j1900     total:245  pass:217  dwarn:0   dfail:0   fail:0   skip:28 
fi-byt-n2820     total:245  pass:213  dwarn:0   dfail:0   fail:0   skip:32 
fi-hsw-4770      total:245  pass:225  dwarn:0   dfail:0   fail:0   skip:20 
fi-hsw-4770r     total:245  pass:225  dwarn:0   dfail:0   fail:0   skip:20 
fi-ilk-650       total:245  pass:192  dwarn:0   dfail:0   fail:0   skip:53 
fi-ivb-3520m     total:245  pass:223  dwarn:0   dfail:0   fail:0   skip:22 
fi-ivb-3770      total:245  pass:223  dwarn:0   dfail:0   fail:0   skip:22 
fi-kbl-7500u     total:245  pass:223  dwarn:0   dfail:0   fail:0   skip:22 
fi-skl-6260u     total:245  pass:231  dwarn:0   dfail:0   fail:0   skip:14 
fi-skl-6700hq    total:245  pass:224  dwarn:0   dfail:0   fail:0   skip:21 
fi-skl-6700k     total:245  pass:223  dwarn:1   dfail:0   fail:0   skip:21 
fi-skl-6770hq    total:245  pass:231  dwarn:0   dfail:0   fail:0   skip:14 
fi-snb-2520m     total:245  pass:212  dwarn:1   dfail:0   fail:0   skip:32 
fi-snb-2600      total:245  pass:212  dwarn:0   dfail:0   fail:0   skip:33 

c744533b1d54437a7986108711de03523d591b27 drm-tip: 2016y-11m-25d-15h-02m-01s UTC integration manifest
c7abfad drm: Avoid NULL dereference for DRM_LEGACY debug message
0dc209e drm: Use u64_to_user_ptr() helper for blob ioctls

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_3118/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Intel-gfx] [PATCH 1/3] drm: Use u64_to_user_ptr() helper for blob ioctls
  2016-11-27 17:09 [PATCH 1/3] drm: Use u64_to_user_ptr() helper for blob ioctls Chris Wilson
                   ` (2 preceding siblings ...)
  2016-11-27 17:45 ` ✗ Fi.CI.BAT: warning for series starting with [1/3] drm: Use u64_to_user_ptr() helper for blob ioctls Patchwork
@ 2016-11-28  7:06 ` Joonas Lahtinen
  3 siblings, 0 replies; 7+ messages in thread
From: Joonas Lahtinen @ 2016-11-28  7:06 UTC (permalink / raw)
  To: Chris Wilson, dri-devel; +Cc: intel-gfx

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
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Intel-gfx] [PATCH 3/3] drm: Fix shift operations for drm_fb_helper::drm_target_preferred()
  2016-11-27 17:09 ` [PATCH 3/3] drm: Fix shift operations for drm_fb_helper::drm_target_preferred() Chris Wilson
@ 2016-11-28  7:18   ` Daniel Vetter
  2016-11-28  8:18   ` Joonas Lahtinen
  1 sibling, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2016-11-28  7:18 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx, dri-devel

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

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Intel-gfx] [PATCH 3/3] drm: Fix shift operations for drm_fb_helper::drm_target_preferred()
  2016-11-27 17:09 ` [PATCH 3/3] drm: Fix shift operations for drm_fb_helper::drm_target_preferred() Chris Wilson
  2016-11-28  7:18   ` [Intel-gfx] " Daniel Vetter
@ 2016-11-28  8:18   ` Joonas Lahtinen
  1 sibling, 0 replies; 7+ messages in thread
From: Joonas Lahtinen @ 2016-11-28  8:18 UTC (permalink / raw)
  To: Chris Wilson, dri-devel; +Cc: 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
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2016-11-28  8:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-27 17:09 [PATCH 1/3] drm: Use u64_to_user_ptr() helper for blob ioctls Chris Wilson
2016-11-27 17:09 ` [PATCH 2/3] drm: Avoid NULL dereference for DRM_LEGACY debug message Chris Wilson
2016-11-27 17:09 ` [PATCH 3/3] drm: Fix shift operations for drm_fb_helper::drm_target_preferred() Chris Wilson
2016-11-28  7:18   ` [Intel-gfx] " Daniel Vetter
2016-11-28  8:18   ` Joonas Lahtinen
2016-11-27 17:45 ` ✗ Fi.CI.BAT: warning for series starting with [1/3] drm: Use u64_to_user_ptr() helper for blob ioctls Patchwork
2016-11-28  7:06 ` [Intel-gfx] [PATCH 1/3] " Joonas Lahtinen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.