drm/i915: Don't use uninitialized 'ret'
diff mbox series

Message ID 20200207152228.1054-1-ville.syrjala@linux.intel.com
State New
Headers show
Series
  • drm/i915: Don't use uninitialized 'ret'
Related show

Commit Message

Ville Syrjälä Feb. 7, 2020, 3:22 p.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Accidentally removed the 'ret=0' initialization, and thus
we're potentially looking at some stack garbage here.

The whole 'ret = do_stuff; if (!ret) do_other_stuff;' pattern
confuses my brain so let's replace it with the standard
immediate return thing.

Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
Fixes: 28a30b45f5e9 ("drm/i915: Convert cdclk to global state")
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Chris Wilson Feb. 7, 2020, 3:24 p.m. UTC | #1
Quoting Ville Syrjala (2020-02-07 15:22:28)
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Accidentally removed the 'ret=0' initialization, and thus
> we're potentially looking at some stack garbage here.
> 
> The whole 'ret = do_stuff; if (!ret) do_other_stuff;' pattern
> confuses my brain so let's replace it with the standard
> immediate return thing.
> 
> Reported-by: Chris Wilson <chris@chris-wilson.co.uk>
> Fixes: 28a30b45f5e9 ("drm/i915: Convert cdclk to global state")
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_display.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 80eebdc4c670..61ba1f2256a0 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -12843,11 +12843,13 @@ static int intel_crtc_atomic_check(struct intel_atomic_state *state,
>         }
>  
>         if (INTEL_GEN(dev_priv) >= 9) {
> -               if (mode_changed || crtc_state->update_pipe)
> +               if (mode_changed || crtc_state->update_pipe) {
>                         ret = skl_update_scaler_crtc(crtc_state);
> -               if (!ret)
> -                       ret = intel_atomic_setup_scalers(dev_priv, crtc,
> -                                                        crtc_state);
> +                       if (ret)
> +                               return ret;
> +               }
> +
> +               ret = intel_atomic_setup_scalers(dev_priv, crtc, crtc_state);
>                 if (ret)
>                         return ret;

Story checks out.
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 80eebdc4c670..61ba1f2256a0 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -12843,11 +12843,13 @@  static int intel_crtc_atomic_check(struct intel_atomic_state *state,
 	}
 
 	if (INTEL_GEN(dev_priv) >= 9) {
-		if (mode_changed || crtc_state->update_pipe)
+		if (mode_changed || crtc_state->update_pipe) {
 			ret = skl_update_scaler_crtc(crtc_state);
-		if (!ret)
-			ret = intel_atomic_setup_scalers(dev_priv, crtc,
-							 crtc_state);
+			if (ret)
+				return ret;
+		}
+
+		ret = intel_atomic_setup_scalers(dev_priv, crtc, crtc_state);
 		if (ret)
 			return ret;
 	}