[PATCH] drm/i915: Avoid divide by zero

Mika Kahola mika.kahola at intel.com
Mon Jan 21 14:29:42 UTC 2019


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..fe358957456e 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;
+	total_width == 0 ? alloc->start = 0 :
+		ddb_size * width_before_pipe / total_width;
+	total_width == 0 ? alloc->end = 0 :
+		ddb_size * (width_before_pipe + pipe_width) / total_width;
 }
 
 static unsigned int skl_cursor_allocation(int num_active)
-- 
2.17.1



More information about the Intel-gfx-trybot mailing list