[Intel-gfx] [PATCH] drm/i915: Avoid divide by zero

Ville Syrjälä ville.syrjala at linux.intel.com
Tue Jan 22 19:09:25 UTC 2019


On Tue, Jan 22, 2019 at 08:09:40PM +0200, Jani Nikula wrote:
> On Tue, 22 Jan 2019, Ville Syrjälä <ville.syrjala at linux.intel.com> wrote:
> > On Tue, Jan 22, 2019 at 02:58:24PM +0200, Mika Kahola wrote:
> >> Avoid divide by zero warning on static analysis.
> >> 
> >> Signed-off-by: Mika Kahola <mika.kahola at intel.com>
> >> ---
> >>  drivers/gpu/drm/i915/intel_pm.c | 6 ++++--
> >>  1 file changed, 4 insertions(+), 2 deletions(-)
> >> 
> >> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> >> index 8b63afa3a221..6a8e8b3f44c2 100644
> >> --- a/drivers/gpu/drm/i915/intel_pm.c
> >> +++ b/drivers/gpu/drm/i915/intel_pm.c
> >> @@ -3912,8 +3912,10 @@ skl_ddb_get_pipe_allocation_limits(struct drm_i915_private *dev_priv,
> >>  			pipe_width = hdisplay;
> >>  	}
> >>  
> >> -	alloc->start = ddb_size * width_before_pipe / total_width;
> >> -	alloc->end = ddb_size * (width_before_pipe + pipe_width) / total_width;
> >> +	alloc->start = total_width == 0 ?
> >> +		0 : ddb_size * width_before_pipe / total_width;
> >> +	alloc->end = total_width == 0 ?
> >> +		0 : ddb_size * (width_before_pipe + pipe_width) / total_width;
> >
> > Can't happen.
> 
> Yeah, it's about stfu the checker...

Feels like the tip of an iceberg. How many more uglies are we going to
have to add?

> 
> >
> >>  }
> >>  
> >>  static unsigned int skl_cursor_allocation(int num_active)
> >> -- 
> >> 2.17.1
> >> 
> >> _______________________________________________
> >> Intel-gfx mailing list
> >> Intel-gfx at lists.freedesktop.org
> >> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> -- 
> Jani Nikula, Intel Open Source Graphics Center

-- 
Ville Syrjälä
Intel


More information about the Intel-gfx mailing list