intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/i915: protect against division by zero.
@ 2018-08-23  0:51 Rodrigo Vivi
  2018-08-23  1:14 ` ✗ Fi.CI.BAT: failure for " Patchwork
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Rodrigo Vivi @ 2018-08-23  0:51 UTC (permalink / raw)
  To: intel-gfx; +Cc: Rodrigo Vivi

Static analyzer tools thinks it is possible to have a division by zero
here.

I don't believe we would really reach this path without any crtc enabled,
but may be good to protect against some unexpected path or behavior.

Fixes: cf1f697acb04 ("drm/i915/skl: distribute DDB based on panel resolution")
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mahesh Kumar <mahesh1.kumar@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
 drivers/gpu/drm/i915/intel_pm.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index d99e5fabe93c..fac6e159a640 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -3878,6 +3878,12 @@ skl_ddb_get_pipe_allocation_limits(struct drm_device *dev,
 			pipe_width = hdisplay;
 	}
 
+	if (WARN_ON(total_width == 0)) {
+		alloc->start = 0;
+		alloc->end = 0;
+		return;
+	}
+
 	alloc->start = ddb_size * width_before_pipe / total_width;
 	alloc->end = ddb_size * (width_before_pipe + pipe_width) / total_width;
 }
-- 
2.17.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2018-08-23  5:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-23  0:51 [PATCH] drm/i915: protect against division by zero Rodrigo Vivi
2018-08-23  1:14 ` ✗ Fi.CI.BAT: failure for " Patchwork
2018-08-23  2:15 ` ✓ Fi.CI.BAT: success " Patchwork
2018-08-23  3:28 ` ✓ Fi.CI.IGT: " Patchwork
2018-08-23  5:11 ` [PATCH] " Maarten Lankhorst
2018-08-23  5:24   ` Rodrigo Vivi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).