All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i915: don't call drm_atomic_state_put on invalid pointer
@ 2016-10-18 15:16 Arnd Bergmann
  2016-10-18 15:29   ` Eric Engestrom
  2016-10-18 15:56   ` Chris Wilson
  0 siblings, 2 replies; 7+ messages in thread
From: Arnd Bergmann @ 2016-10-18 15:16 UTC (permalink / raw)
  To: Daniel Vetter, Jani Nikula, David Airlie
  Cc: Arnd Bergmann, Chris Wilson, Daniel Vetter,
	Ville Syrjälä,
	Maarten Lankhorst, Imre Deak, Ander Conselvan de Oliveira,
	intel-gfx, dri-devel, linux-kernel

The introduction of reference counting on the state structures caused
sanitize_watermarks() in i915 to break in the error handling case,
as pointed out by gcc -Wmaybe-uninitialized

drivers/gpu/drm/i915/intel_display.c: In function ‘intel_modeset_init’:
include/drm/drm_atomic.h:224:2: error: ‘state’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

This changes the function back to only drop the reference count
when it was successfully allocated first.

Fixes: 0853695c3ba4 ("drm: Add reference counting to drm_atomic_state")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/gpu/drm/i915/intel_display.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 6d168685bbda..6a26da143aa6 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -16314,7 +16314,7 @@ static void sanitize_watermarks(struct drm_device *dev)
 		 * BIOS-programmed watermarks untouched and hope for the best.
 		 */
 		WARN(true, "Could not determine valid watermarks for inherited state\n");
-		goto fail;
+		goto put_state;
 	}
 
 	/* Write calculated watermark values back */
@@ -16325,8 +16325,9 @@ static void sanitize_watermarks(struct drm_device *dev)
 		dev_priv->display.optimize_watermarks(cs);
 	}
 
-fail:
+put_state:
 	drm_atomic_state_put(state);
+fail:
 	drm_modeset_drop_locks(&ctx);
 	drm_modeset_acquire_fini(&ctx);
 }
-- 
2.9.0

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

* Re: [PATCH] i915: don't call drm_atomic_state_put on invalid pointer
  2016-10-18 15:16 [PATCH] i915: don't call drm_atomic_state_put on invalid pointer Arnd Bergmann
@ 2016-10-18 15:29   ` Eric Engestrom
  2016-10-18 15:56   ` Chris Wilson
  1 sibling, 0 replies; 7+ messages in thread
From: Eric Engestrom @ 2016-10-18 15:29 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Daniel Vetter, Jani Nikula, David Airlie,
	Ander Conselvan de Oliveira, Daniel Vetter, linux-kernel,
	dri-devel, intel-gfx

On Tuesday, 2016-10-18 17:16:23 +0200, Arnd Bergmann wrote:
> The introduction of reference counting on the state structures caused
> sanitize_watermarks() in i915 to break in the error handling case,
> as pointed out by gcc -Wmaybe-uninitialized
> 
> drivers/gpu/drm/i915/intel_display.c: In function ‘intel_modeset_init’:
> include/drm/drm_atomic.h:224:2: error: ‘state’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> This changes the function back to only drop the reference count
> when it was successfully allocated first.
> 
> Fixes: 0853695c3ba4 ("drm: Add reference counting to drm_atomic_state")
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>

> ---
>  drivers/gpu/drm/i915/intel_display.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 6d168685bbda..6a26da143aa6 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -16314,7 +16314,7 @@ static void sanitize_watermarks(struct drm_device *dev)
>  		 * BIOS-programmed watermarks untouched and hope for the best.
>  		 */
>  		WARN(true, "Could not determine valid watermarks for inherited state\n");
> -		goto fail;
> +		goto put_state;
>  	}
>  
>  	/* Write calculated watermark values back */
> @@ -16325,8 +16325,9 @@ static void sanitize_watermarks(struct drm_device *dev)
>  		dev_priv->display.optimize_watermarks(cs);
>  	}
>  
> -fail:
> +put_state:
>  	drm_atomic_state_put(state);
> +fail:
>  	drm_modeset_drop_locks(&ctx);
>  	drm_modeset_acquire_fini(&ctx);
>  }
> -- 
> 2.9.0

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

* Re: [PATCH] i915: don't call drm_atomic_state_put on invalid pointer
@ 2016-10-18 15:29   ` Eric Engestrom
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Engestrom @ 2016-10-18 15:29 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Ander Conselvan de Oliveira, David Airlie, Daniel Vetter,
	intel-gfx, linux-kernel, dri-devel, Daniel Vetter

On Tuesday, 2016-10-18 17:16:23 +0200, Arnd Bergmann wrote:
> The introduction of reference counting on the state structures caused
> sanitize_watermarks() in i915 to break in the error handling case,
> as pointed out by gcc -Wmaybe-uninitialized
> 
> drivers/gpu/drm/i915/intel_display.c: In function ‘intel_modeset_init’:
> include/drm/drm_atomic.h:224:2: error: ‘state’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> This changes the function back to only drop the reference count
> when it was successfully allocated first.
> 
> Fixes: 0853695c3ba4 ("drm: Add reference counting to drm_atomic_state")
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>

> ---
>  drivers/gpu/drm/i915/intel_display.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 6d168685bbda..6a26da143aa6 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -16314,7 +16314,7 @@ static void sanitize_watermarks(struct drm_device *dev)
>  		 * BIOS-programmed watermarks untouched and hope for the best.
>  		 */
>  		WARN(true, "Could not determine valid watermarks for inherited state\n");
> -		goto fail;
> +		goto put_state;
>  	}
>  
>  	/* Write calculated watermark values back */
> @@ -16325,8 +16325,9 @@ static void sanitize_watermarks(struct drm_device *dev)
>  		dev_priv->display.optimize_watermarks(cs);
>  	}
>  
> -fail:
> +put_state:
>  	drm_atomic_state_put(state);
> +fail:
>  	drm_modeset_drop_locks(&ctx);
>  	drm_modeset_acquire_fini(&ctx);
>  }
> -- 
> 2.9.0
_______________________________________________
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: [PATCH] i915: don't call drm_atomic_state_put on invalid pointer
  2016-10-18 15:16 [PATCH] i915: don't call drm_atomic_state_put on invalid pointer Arnd Bergmann
@ 2016-10-18 15:56   ` Chris Wilson
  2016-10-18 15:56   ` Chris Wilson
  1 sibling, 0 replies; 7+ messages in thread
From: Chris Wilson @ 2016-10-18 15:56 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Daniel Vetter, Jani Nikula, David Airlie, Daniel Vetter,
	Ville Syrjälä,
	Maarten Lankhorst, Imre Deak, Ander Conselvan de Oliveira,
	intel-gfx, dri-devel, linux-kernel

On Tue, Oct 18, 2016 at 05:16:23PM +0200, Arnd Bergmann wrote:
> The introduction of reference counting on the state structures caused
> sanitize_watermarks() in i915 to break in the error handling case,
> as pointed out by gcc -Wmaybe-uninitialized
> 
> drivers/gpu/drm/i915/intel_display.c: In function ‘intel_modeset_init’:
> include/drm/drm_atomic.h:224:2: error: ‘state’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> This changes the function back to only drop the reference count
> when it was successfully allocated first.
> 
> Fixes: 0853695c3ba4 ("drm: Add reference counting to drm_atomic_state")
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Yup, missed that it jumps to fail before allocating state.

Function still looks a bit odd, but nvm
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

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

* Re: [PATCH] i915: don't call drm_atomic_state_put on invalid pointer
@ 2016-10-18 15:56   ` Chris Wilson
  0 siblings, 0 replies; 7+ messages in thread
From: Chris Wilson @ 2016-10-18 15:56 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Ander Conselvan de Oliveira, David Airlie, Daniel Vetter,
	linux-kernel, dri-devel, Daniel Vetter, intel-gfx

On Tue, Oct 18, 2016 at 05:16:23PM +0200, Arnd Bergmann wrote:
> The introduction of reference counting on the state structures caused
> sanitize_watermarks() in i915 to break in the error handling case,
> as pointed out by gcc -Wmaybe-uninitialized
> 
> drivers/gpu/drm/i915/intel_display.c: In function ‘intel_modeset_init’:
> include/drm/drm_atomic.h:224:2: error: ‘state’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> This changes the function back to only drop the reference count
> when it was successfully allocated first.
> 
> Fixes: 0853695c3ba4 ("drm: Add reference counting to drm_atomic_state")
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Yup, missed that it jumps to fail before allocating state.

Function still looks a bit odd, but nvm
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
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] i915: don't call drm_atomic_state_put on invalid pointer
  2016-10-18 15:56   ` Chris Wilson
@ 2016-10-19  7:25     ` Daniel Vetter
  -1 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2016-10-19  7:25 UTC (permalink / raw)
  To: Chris Wilson, Arnd Bergmann, Daniel Vetter, Jani Nikula,
	David Airlie, Daniel Vetter, Ville Syrjälä,
	Maarten Lankhorst, Imre Deak, Ander Conselvan de Oliveira,
	intel-gfx, dri-devel, linux-kernel

On Tue, Oct 18, 2016 at 04:56:02PM +0100, Chris Wilson wrote:
> On Tue, Oct 18, 2016 at 05:16:23PM +0200, Arnd Bergmann wrote:
> > The introduction of reference counting on the state structures caused
> > sanitize_watermarks() in i915 to break in the error handling case,
> > as pointed out by gcc -Wmaybe-uninitialized
> > 
> > drivers/gpu/drm/i915/intel_display.c: In function ‘intel_modeset_init’:
> > include/drm/drm_atomic.h:224:2: error: ‘state’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> > 
> > This changes the function back to only drop the reference count
> > when it was successfully allocated first.
> > 
> > Fixes: 0853695c3ba4 ("drm: Add reference counting to drm_atomic_state")
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 
> Yup, missed that it jumps to fail before allocating state.
> 
> Function still looks a bit odd, but nvm
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Applied to drm-misc, thanks for the patch&review.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

* Re: [Intel-gfx] [PATCH] i915: don't call drm_atomic_state_put on invalid pointer
@ 2016-10-19  7:25     ` Daniel Vetter
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Vetter @ 2016-10-19  7:25 UTC (permalink / raw)
  To: Chris Wilson, Arnd Bergmann, Daniel Vetter, Jani Nikula,
	David Airlie, Daniel Vetter, Ville Syrjälä,
	Maarten Lankhorst, Imre Deak, Ander Conselvan de Oliveira,
	intel-gfx, dri-devel, linux-kernel

On Tue, Oct 18, 2016 at 04:56:02PM +0100, Chris Wilson wrote:
> On Tue, Oct 18, 2016 at 05:16:23PM +0200, Arnd Bergmann wrote:
> > The introduction of reference counting on the state structures caused
> > sanitize_watermarks() in i915 to break in the error handling case,
> > as pointed out by gcc -Wmaybe-uninitialized
> > 
> > drivers/gpu/drm/i915/intel_display.c: In function ‘intel_modeset_init’:
> > include/drm/drm_atomic.h:224:2: error: ‘state’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> > 
> > This changes the function back to only drop the reference count
> > when it was successfully allocated first.
> > 
> > Fixes: 0853695c3ba4 ("drm: Add reference counting to drm_atomic_state")
> > Cc: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> 
> Yup, missed that it jumps to fail before allocating state.
> 
> Function still looks a bit odd, but nvm
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>

Applied to drm-misc, thanks for the patch&review.
-Daniel
-- 
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

end of thread, other threads:[~2016-10-19 14:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-18 15:16 [PATCH] i915: don't call drm_atomic_state_put on invalid pointer Arnd Bergmann
2016-10-18 15:29 ` Eric Engestrom
2016-10-18 15:29   ` Eric Engestrom
2016-10-18 15:56 ` Chris Wilson
2016-10-18 15:56   ` Chris Wilson
2016-10-19  7:25   ` [Intel-gfx] " Daniel Vetter
2016-10-19  7:25     ` Daniel Vetter

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.