diff mbox series

drm/i915: Initialise outparam for error return from wait_for_register

Message ID 20200819115407.17519-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series drm/i915: Initialise outparam for error return from wait_for_register | expand

Commit Message

Chris Wilson Aug. 19, 2020, 11:54 a.m. UTC
Just in case the caller passes in 0 for both slow&fast timeouts, make
sure we initialise the stack value returned. Add an assert so that we
don't make the mistake of passing 0 timeouts for the wait.

drivers/gpu/drm/i915/intel_uncore.c:2011 __intel_wait_for_register_fw() error: uninitialized symbol 'reg_value'.

References: 3f649ab728cd ("treewide: Remove uninitialized_var() usage")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_uncore.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Souza, Jose Aug. 19, 2020, 11:43 p.m. UTC | #1
On Wed, 2020-08-19 at 12:54 +0100, Chris Wilson wrote:
> Just in case the caller passes in 0 for both slow&fast timeouts, make
> sure we initialise the stack value returned. Add an assert so that we
> don't make the mistake of passing 0 timeouts for the wait.
> 
> drivers/gpu/drm/i915/intel_uncore.c:2011 __intel_wait_for_register_fw() error: uninitialized symbol 'reg_value'.
> 

Reviewed-by: José Roberto de Souza <jose.souza@intel.com>

> References: 3f649ab728cd ("treewide: Remove uninitialized_var() usage")
> Signed-off-by: Chris Wilson <
> chris@chris-wilson.co.uk
> >
> ---
>  drivers/gpu/drm/i915/intel_uncore.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
> index 8d5a933e6af6..263ffcb832b7 100644
> --- a/drivers/gpu/drm/i915/intel_uncore.c
> +++ b/drivers/gpu/drm/i915/intel_uncore.c
> @@ -1993,13 +1993,14 @@ int __intel_wait_for_register_fw(struct intel_uncore *uncore,
>  				 unsigned int slow_timeout_ms,
>  				 u32 *out_value)
>  {
> -	u32 reg_value;
> +	u32 reg_value = 0;
>  #define done (((reg_value = intel_uncore_read_fw(uncore, reg)) & mask) == value)
>  	int ret;
>  
>  	/* Catch any overuse of this function */
>  	might_sleep_if(slow_timeout_ms);
>  	GEM_BUG_ON(fast_timeout_us > 20000);
> +	GEM_BUG_ON(!fast_timeout_us && !slow_timeout_ms);
>  
>  	ret = -ETIMEDOUT;
>  	if (fast_timeout_us && fast_timeout_us <= 20000)
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index 8d5a933e6af6..263ffcb832b7 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -1993,13 +1993,14 @@  int __intel_wait_for_register_fw(struct intel_uncore *uncore,
 				 unsigned int slow_timeout_ms,
 				 u32 *out_value)
 {
-	u32 reg_value;
+	u32 reg_value = 0;
 #define done (((reg_value = intel_uncore_read_fw(uncore, reg)) & mask) == value)
 	int ret;
 
 	/* Catch any overuse of this function */
 	might_sleep_if(slow_timeout_ms);
 	GEM_BUG_ON(fast_timeout_us > 20000);
+	GEM_BUG_ON(!fast_timeout_us && !slow_timeout_ms);
 
 	ret = -ETIMEDOUT;
 	if (fast_timeout_us && fast_timeout_us <= 20000)